{
#region Variables
private DataSeries Var1;
private DataSeries Var2;
#endregion
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Plot1"));
Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGree n), 50, "FiftyLine"));
Var1= new DataSeries(this);
Var2 = new DataSeries(this);
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
}
protected override void OnBarUpdate()
{
if (CurrentBar < 30) return;
if(Close[0] > Open[0])
{
//the sum of the volume of the last 30 bars
Var1.Set(SUM(Volume,30)[0]);
}
else
{
//minus the currentbar's volume that are false
Var1.Set(SUM(Volume, 30)[0] - Volume[0]);
}
//difine Var2
Var2.Set((Var1[0]/SUM(Volume, 30)[0])*100);
// draw the line according to the calculation
Plot1.Set( Var2[0]);
}
Comment