I am trying to cause an indicator... the MAX indicator that is pre-installed in NT8... to use the High of the bar instead of the close.
I am familiar with creating a template Default once the indicator is on the chart. That doesn't seem to hold the High value choice if I set the template to default.
Can I code this in Ninjascript after creating a copy of the standard MAX indicator?
Somewhere in State.Configure by chance?
For reference here is the most relevant code in the MAX indicator where I believe the change would need to be made...
else if (State == State.Configure)
{
lastBar = 0;
lastMax = 0;
runningMax = 0;
runningBar = 0;
thisBar = 0;
}
}
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
{
runningMax = Input[0];
lastMax = Input[0];
runningBar = 0;
lastBar = 0;
thisBar = 0;
Value[0] = Input[0];
return;
}
if (CurrentBar - runningBar >= Period || CurrentBar < thisBar)
{
runningMax = double.MinValue;
for (int barsBack = Math.Min(CurrentBar, Period - 1); barsBack > 0; barsBack--)
if (Input[barsBack] >= runningMax)
{
runningMax = Input[barsBack];
runningBar = CurrentBar - barsBack;
}
}
if (thisBar != CurrentBar)
{
lastMax = runningMax;
lastBar = runningBar;
thisBar = CurrentBar;
}
if (Input[0] >= lastMax)
{
runningMax = Input[0];
runningBar = CurrentBar;
}
else
{
runningMax = lastMax;
runningBar = lastBar;
}
Value[0] = runningMax;

Comment