Hello,
I'm striving to pinpoint the high and low levels of the first four-hour trading bar, encompassing the pre-market period, utilizing 30-minute aggregated data. I have attached a code, but it is not able to hold the data constant throughout the trading period by using 30 minute data. My aim is to establish constant high and low values based on the first four-hour bar, which can then be monitored through 30-minute interval aggregation. Please correct.
Thanks
I'm striving to pinpoint the high and low levels of the first four-hour trading bar, encompassing the pre-market period, utilizing 30-minute aggregated data. I have attached a code, but it is not able to hold the data constant throughout the trading period by using 30 minute data. My aim is to establish constant high and low values based on the first four-hour bar, which can then be monitored through 30-minute interval aggregation. Please correct.
Thanks
Code:
def firstBarNumber = if GetDay() <> GetDay()[1] then BarNumber() else firstBarNumber[1];
def high1 = if BarNumber() == firstBarNumber then high(period=aggregationPeriod.THIRTY_MIN) else high1[1];
def low1 = if BarNumber() == firstBarNumber then low(period=aggregationPeriod.THIRTY_MIN) else low1[1];
def high2 = if BarNumber() == firstBarNumber+7 then high(period=aggregationPeriod.THIRTY_MIN) else high2[1];
def low2 = if BarNumber() == firstBarNumber+7 then low(period=aggregationPeriod.THIRTY_MIN) else low2[1];
def hi = if high1>=high2 then high1 else high2;
def lo = if low1<=low2 then low1 else low2;
plot IBH = hi ;
plot IBL = lo;