I am trying to build daily bars out of 5 min bars.. The code is below, its just a snippet ok, its just a rough bare bones proof of concept thing.. Anyway, when I fire it, it says its trying to reference future data, i need to have a way where this code fires only during the last couple days of the chart... I am thinking thats what i need to do..
Any help or ideas will be appreciated.
Here is code:
Code: Select all
vBarNumber = BarNumber;
if T >= DayEndTime and T[1] < DayEndTime then begin
value1 = findbar(calcdate(date,-2),0);
value2 = findbar(calcdate(date,-1),0);
counter = 1;
for counter = value1 to value2-value1 begin
if Synthetic_DailyBar_Date[vDaysBack] = date[counter] and time[counter]>0 and time[counter]<DayEndTime then begin
Synthetic_DailyBar_High[vDaysBack] = maxlist(Synthetic_DailyBar_High[vDaysBack],high[counter]);
Synthetic_DailyBar_Low[vDaysBack]= minlist(Synthetic_DailyBar_High[vDaysBack],low[counter]);
Synthetic_DailyBar_NbrBarsIterated[vDaysBack] = Synthetic_DailyBar_NbrBarsIterated[vDaysBack]+1;
end;
end;
print
(
"Date: ",NumToStr(Synthetic_DailyBar_Date[vDaysBack],4),
"High = ",NumToStr(Synthetic_DailyBar_High[vDaysBack],4),
"Low = ",NumToStr(Synthetic_DailyBar_Low[vDaysBack],4),
"Iterated = ", NumToStr(Synthetic_DailyBar_NbrBarsIterated[vDaysBack],0)
);
end;