if (High[0]>htphigh) htphigh = High[0];
if (Low[0]<htplow) htplow = Low[0];
Basically I am accumulating the highest high and lowest low for N bars. This works fine for live data coming but for some strange reason htphigh and htplow have the highest and lowest close getting assigned for historic data.
I figured that it may be OnBarUpdate only being called once a bar on historical data but High [0] should still return the high of the bar should it not? I am tearing my hair out here and hoped that someone could point out where I am beeing stupid!
The complete snipet just in case--------
if (CurrentBar != oldbar){ //new bar?
oldbar = CurrentBar;
n = n - 1 ; // count it
if (n == 0) { // reset N period high and low
n = periods;
htphigh = Open[0];
htplow = Open[0];
}
}
if (High[0]>htphigh) htphigh = High[0];
if (Low[0]<htplow) htplow = Low[0];
Comment