I don't know much of programming. I am trying to mark medium term high on the chart which is higher than previous short term high and next short term high.
Short term high is high which is higher than previous 2 highs as well as next to highs.
I am able to mark short term highs on the chart using following formula (screen shot attached)
protected override void OnBarUpdate()
{
if (CurrentBar < 10)
return;
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
if(High[0] > High[1] && High[0] > High[2] && High[0] > High[-1] && High[0] > High[-2])
DrawArrowDown(CurrentBar.ToString(), true, 0, High[0] + TickSize, Color.Red);
if (Low[0] < Low[1] && Low[0] < Low[2] && Low[0] < Low[-1] && Low[0] < Low[-2])
DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Green);
(This also gives short term lows similar ways)
But I am not able to mark medium term high. I tried different ways but it does not work.
Medium term High is a HIGH greater than previous short term high and greater than next short term high as well (middle out of 3 short term high which is highest)
I was able to do in other platform where "valuewhen" function is allowed
j = valuewhen (b, high, 2) where j is double and b bool. b = High[0] and (High[0] > High[1] && High[0] > High[2] && High[0] > High[-1] && High[0] > High[-2])
I am not able to do this in Ninjatrader (recently started using Ninja trader and love it)
screen shot attached
Comment