When one has the N Bars Up and N Bars Down indicators and wishes to incorporate them into a strategy, an ambiguity arises because both indicators return the value 1 using the same return variable, value = 1.
protected override void OnBarUpdate()
{
// Evaluates if we have 3 consecutive higher closes
double value=NBarsUp(3,true,true,true)[0];
if(value==1)
Print("We have three consecutive higher closes");
// Evaluates if we have 3 consecutive lower closes
double value=NBarsDown(3,true,true,true)[0];
if(value==1)
Print("We have three consecutive lower closes");
}
AddPlot(new Stroke(Brushes.Crimson, 2), PlotStyle.Bar, NinjaTrader.Custom.Resource.NBarsDownTrigger); AddPlot(new Stroke(Brushes.DarkCyan, 2), PlotStyle.Bar, NinjaTrader.Custom.Resource.NinjaScriptIndicatorDi ff);
By
AddPlot(new Stroke(Brushes.DarkCyan, 2), PlotStyle.Bar, "NBarsDownPlot"); AddPlot(new Stroke(Brushes.Crimson, 2), PlotStyle.Bar, "NBarsUpPlot");
In the script, i can then use them as follows:
NBarsDownPlot[0] = 1; NBarsUpPlot[1];
I noticed in the data box and both panels that there are two values:
Trigger=1 or 0,
Diff =1 or 0,
which are returned by these two indicators.
Where can I find these values, and how can I access them for use without modifying the code?
Thank you for the time you've dedicated to helping us.

Comment