It draws volume above and below bars on the chart. It was basically an experiment in learning Ninjascript.
What I would like to know is it possible to limit how far back the indicator draws draws bars?
I have another indicator which requires loading lots of days of data, but I'm working on a new indicator which I would only like to draw the last 10 bars.
Is that possible?
The code:
//create a class-level variable called myVolume
private double myVolume;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "VolumeAboveAndBelow";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
//assign the VOL[0] indicator value to the double variable
myVolume = VOL()[0];
//check for up bar and use Draw.Text() to draw variable value on chart
if (Close[0] > Open[0])
Draw.Text(this, "vol up bar" + CurrentBar, myVolume.ToString(), 0, High[0] + 5 * TickSize, Brushes.Red);
//check for download bar and use Draw.Text() to draw variable value on chart
if (Open[0] >= Close[0])
Draw.Text(this, "vol up bar" + CurrentBar, myVolume.ToString(), 0, Low[0] - 5 * TickSize, Brushes.ForestGreen);
}
}
}

Comment