Jungs, ich brauche mal bitte eure Hilfe. Der Code: //
// Copyright (C) 2007, NinjaTrader LLC <www.ninjatrader.com>.
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// The Accumulation/Distribution (AD) study attempts to quantify the amount of volume flowing into or out of an instrument by identifying the position of the close of the period in relation to that period�s high/low range.
/// </summary>
[Description("Effective Volume as described in 'Value in Time' by Pascal Willain -- A modified version of Williams A/D indicator")]
public class EffectiveVolume : Indicator
{
#region Variables
// Wizard generated variables
private int _aLength = 5;
private int _eLength = 3;
private double _aPhase = 0;
private double _ePhase = 0;
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(new Pen(Color.Transparent, 5.0f), PlotStyle.Bar, "EffectiveVolume"));//0
Add(new Plot(new Pen(Color.Chartreuse, 4.0f), PlotStyle.Line, "EffectiveVolume+"));//1
Add(new Plot(new Pen(Color.OrangeRed, 4.0f), PlotStyle.Line, "EffectiveVolume-"));//2
Add(new Plot(new Pen(Color.Transparent, 5.0f), PlotStyle.Bar, "ActualVolume")); //3
Add(new Plot(new Pen(Color.Transparent, 5.0f), PlotStyle.Bar, "ActualVolume+")); //4
Add(new Plot(new Pen(Color.Transparent, 5.0f), PlotStyle.Bar, "ActualVolume-")); //5
Add(new Plot(new Pen(Color.Black, 3.0f), PlotStyle.Line, "ActualMA")); //6
Add(new Plot(new Pen(Color.White, 3.0f), PlotStyle.Line, "EffectiveMA")); //7
Add(new Line(Color.Black, 0, "ZeroLine"));
Lines[0].Pen.DashStyle = DashStyle.Dash;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
EffectiveVol.Set((CurrentBar == 0 ? 0 : (High[0] != Low[0] ? ((((Close[1] - Close[0]) + TickSize)) / (Math.Max(High[0], Close[1]) - Math.Min(Low[0], Close[1]) + TickSize)) * -Volume[0] : 0)));
if (EffectiveVol[0] > 0)
{
ActualVolume.Set(Volume[0]);
EffectiveVolUp.Set(EffectiveVol[0]);
ActualVolUp.Set(ActualVolume[0]);
}
else if (EffectiveVol[0] < 0)
{
ActualVolume.Set(-Volume[0]);
EffectiveVolDown.Set(EffectiveVol[0]);
ActualVolDown.Set(ActualVolume[0]);
}
if (CalculateOnBarClose)
{
ActualMA.Set(SMA(ActualVolume, ActualLength)[0]);
EffectiveMA.Set(SMA(EffectiveVol, EffectiveLength)[0]);
}
else if (CurrentBar > 1)
{
ActualMA.Set(1,SMA(ActualVolume, ActualLength)[1]);
EffectiveMA.Set(1,SMA(EffectiveVol, EffectiveLength)[1]);
}
}
#region Properties
[Browsable(false),XmlIgnore()]
public DataSeries EffectiveVol
{
get { return Values[0]; }
}
[Browsable(false),XmlIgnore()]
private DataSeries EffectiveVolUp
{
get { return Values[1]; }
}
[Browsable(false),XmlIgnore()]
private DataSeries EffectiveVolDown
{
get { return Values[2]; }
}
[Browsable(false),XmlIgnore()]
public DataSeries ActualVolume
{
get { return Values[3]; }
}
[Browsable(false),XmlIgnore()]
private DataSeries ActualVolUp
{
get { return Values[4]; }
}
[Browsable(false),XmlIgnore()]
private DataSeries ActualVolDown
{
get { return Values[5]; }
}
[Browsable(false),XmlIgnore()]
private DataSeries ActualMA
{
get { return Values[6]; }
}
[Browsable(false),XmlIgnore()]
private DataSeries EffectiveMA
{
get { return Values[7]; }
}
[Description("ActualVol MA Smooth Length")]
[Category("ActualVol MA Parameters")]
public int ActualLength
{
get { return _aLength; }
set { _aLength = value; }
}
[Description("EffectiveVol MA Smooth Length")]
[Category("EffectiveVol MA Parameters")]
public int EffectiveLength
{
get { return _eLength; }
set { _eLength = value; }
}
[Description("ActualVol MA Phase")]
[Category("ActualVol MA Parameters")]
public double ActualPhase
{
get { return _aPhase; }
set { _aPhase = value; }
}
[Description("EffectiveVol MA Phase")]
[Category("EffectiveVol MA Parameters")]
public double EffectivePhase
{
get { return _ePhase; }
set { _ePhase = value; }
}
#endregion
}
}
#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
public partial class Indicator : IndicatorBase
{
private EffectiveVolume[] cacheEffectiveVolume = null;
private static EffectiveVolume checkEffectiveVolume = new EffectiveVolume();
/// <summary>
/// Effective Volume as described in 'Value in Time' by Pascal Willain -- A modified version of Williams A/D indicator
/// </summary>
/// <returns></returns>
public EffectiveVolume EffectiveVolume()
{
return EffectiveVolume(Input);
}
/// <summary>
/// Effective Volume as described in 'Value in Time' by Pascal Willain -- A modified version of Williams A/D indicator
/// </summary>
/// <returns></returns>
public EffectiveVolume EffectiveVolume(Data.IDataSeries input)
{
if (cacheEffectiveVolume != null)
for (int idx = 0; idx < cacheEffectiveVolume.Length; idx++)
if (cacheEffectiveVolume[idx].EqualsInput(input))
return cacheEffectiveVolume[idx];
EffectiveVolume indicator = new EffectiveVolume();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
indicator.Input = input;
indicator.SetUp();
EffectiveVolume[] tmp = new EffectiveVolume[cacheEffectiveVolume == null ? 1 : cacheEffectiveVolume.Length + 1];
if (cacheEffectiveVolume != null)
cacheEffectiveVolume.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheEffectiveVolume = tmp;
Indicators.Add(indicator);
return indicator;
}
}
}
// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
public partial class Column : ColumnBase
{
/// <summary>
/// Effective Volume as described in 'Value in Time' by Pascal Willain -- A modified version of Williams A/D indicator
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.EffectiveVolume EffectiveVolume()
{
return _indicator.EffectiveVolume(Input);
}
/// <summary>
/// Effective Volume as described in 'Value in Time' by Pascal Willain -- A modified version of Williams A/D indicator
/// </summary>
/// <returns></returns>
public Indicator.EffectiveVolume EffectiveVolume(Data.IDataSeries input)
{
return _indicator.EffectiveVolume(input);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Effective Volume as described in 'Value in Time' by Pascal Willain -- A modified version of Williams A/D indicator
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.EffectiveVolume EffectiveVolume()
{
return _indicator.EffectiveVolume(Input);
}
/// <summary>
/// Effective Volume as described in 'Value in Time' by Pascal Willain -- A modified version of Williams A/D indicator
/// </summary>
/// <returns></returns>
public Indicator.EffectiveVolume EffectiveVolume(Data.IDataSeries input)
{
if (InInitialize && input == null)
throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
return _indicator.EffectiveVolume(input);
}
}
}
#endregion Der Indikator malt ein paar rote/grüne Striche wenn das Volumen entsprechend hoch ist. Ich hab keinen Plan was ich in die STrategie schreiben muss damit ich auf diese roten und grünen Linien zugreifen will. Es soll erstmal ganz einfach sein: Wenn rote Linie sich bildet, dann Sell. Wenn grüne Linie sich bildet, dann Buy. Mit je festen SL/TP. Hat jemand Tipps? Ich steige bei dem Indikator nicht so ganz dahinter. Danke!