Thanks for help. There are two issues here. 1) Bill's formula is shorter but on some days it somehow excludes the first bar (09:30:00 one) from calculations. For example on NQ-H7 five minute chart:
- 2006-12-13: incorrect High - 2007-01-19: incorrect Low - 2007-01-26: incorrect High I double checked my one-minute data and there is nothing missing there. It would be interesting to find out why this is happening. http://img227.imageshack.us/img227/1142/02122007062358ca3.png 2) Edward's formula is the hell of a code. I tried to add Lowest Low plot but adding the following line simply wouldn't work: // assign lowest low within the interval assigned to rest of day lwl = IIf(!tt,LLV(ltt,bs2),Null); Plot(lwl,"",colorOrange,styleLine); Here is what I get: http://img225.imageshack.us/img225/530/02122007063634gx1.png After marking out Plot(lwl, ... ) statement everything is back to normal. Also, there are no problems with Highs or Lows on days when Bill's code generates incorrect values. http://img243.imageshack.us/img243/8375/02122007064123bq7.png Both formulas, with lines for Lowest Low added and a few minor cosmetic changes, are posted below. /*** Bill's code ***/ // High and Low in a specified time frame startTime = 093000; endTime = 103000; start = BarsSince(TimeNum()==startTime); end = BarsSince(TimeNum()==endTime); per = (start - end); hgh = ValueWhen(TimeNum()==endTime, HHV(H, per)); lwl = ValueWhen(TimeNum()==endTime, LLV(L, per)); cls = ValueWhen(TimeNum()==endTime, C); H_plot = IIf(TimeNum()>=endTime, hgh, Null); L_plot = IIf(TimeNum()>=endTime, lwl, Null); C_plot = IIf(TimeNum()>=endTime, cls, Null); Plot(H_plot, "", colorLightBlue, styleLine); Plot(L_plot, "", colorOrange, styleLine); Plot(C_plot, "", colorDarkYellow, styleLine); Plot(C,"",26,64); SetChartOptions(0, chartShowDates); Title = "\\c11"+Interval(2)+" "+ Date()+"\\c-1 H="+H+" L="+L; /*** END ***/ // +++++++++++++++++++++++++++++++ // /*** Edward's code ***/ // High and Low in a specified time frame startTime = 093000; endTime = 103000; // assign an array tt having a value 1 inside the interval tt = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,1,0); // high within interval htt = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,H,0); // low within interval ltt = IIf(TimeNum() >= startTime AND TimeNum() <= endTime,L,0); // start bar of interval is 1, end bar is -1 dtt = tt - Ref(tt,-1); // calculate the cumulative number of bars inside the interval bs = BarsSince( dtt == 1 ) + 1; // find number of bars at the end of interval bs2 = IIf(dtt == -1,bs,Null); // assign highest high within the interval assigned to rest of day hgh = IIf(!tt,HHV(htt,bs2),Null); // assign lowest low within the interval assigned to rest of day lwl = IIf(!tt,LLV(ltt,bs2),Null); // close price at end of interval assigned to rest of day // old code: cls = IIf(!tt,ValueWhen(dtt == -1,C),Null); cls = IIf(!tt,ValueWhen(Ref(dtt,1) == -1,C),Null); Plot(hgh,"",colorLightBlue,styleLine); // Plot(lwl,"",colorOrange,styleLine); // this must be fixed Plot(cls,"",colorDarkYellow,styleLine); Plot(C,"",26,64); Title = "\\c11"+Interval(2)+" "+ Date()+"\\c-1 H="+H+" L="+L; SetChartOptions(0, chartShowDates); /*** END ***/
