Posted By: giantj
Dealing with gaps in MT4 M1 data - 01/04/20 02:46
Hi,
I'm building a strategy where I need the strategy to be run in the 1 minute timeframe but I also need to be build price OHLC for the H1 timeframe.
So I have set by BarPeriod to 1 and I've built series for High, Low and Close by changing the timeframe to 60 / Period ... pretty standard code:
I noticed that occasionally the data downloaded from my MT4 provided has missing entries on the 1 minute timeframe. This seems to impact how the H1 data gets calculated.
For example, if the previous H1 entry was calculated at 1am, and there are 2 missing entries between 1am and 2am, the next H1 entry is only calculated at 2:02am. With my strategy, I check on the hour for the last H1 High and Low values. But in the scenario above, it will still have the previous one stored in H1Close[0], and not the latest one.
Is there a way around this without having to build my own version of priceHigh and priceLow for a 1 hour period to specifically work in a 60 min timeframe rather than the last 60 entries?
Or maybe there is an easy way to pad the historical data where there are missing entries? If so, how would I go about that?
Thanks,
GJ
I'm building a strategy where I need the strategy to be run in the 1 minute timeframe but I also need to be build price OHLC for the H1 timeframe.
So I have set by BarPeriod to 1 and I've built series for High, Low and Close by changing the timeframe to 60 / Period ... pretty standard code:
Code
BarPeriod = 1; BarOffset = 0; StartDate = 20191107; EndDate = 20191111; LookBack = 60/BarPeriod * 24 * 5; MaxLong = MaxShort = 1; TimeFrame = 60 / BarPeriod; FrameOffset = 0; BarOffset = 0; vars H1Close = series(priceClose()); vars H1High = series(priceHigh()); vars H1Low = series(priceLow()); TimeFrame = BarPeriod; vars M1Close = series(priceClose()); vars M1High = series(priceHigh()); vars M1Low = series(priceLow());
I noticed that occasionally the data downloaded from my MT4 provided has missing entries on the 1 minute timeframe. This seems to impact how the H1 data gets calculated.
For example, if the previous H1 entry was calculated at 1am, and there are 2 missing entries between 1am and 2am, the next H1 entry is only calculated at 2:02am. With my strategy, I check on the hour for the last H1 High and Low values. But in the scenario above, it will still have the previous one stored in H1Close[0], and not the latest one.
Is there a way around this without having to build my own version of priceHigh and priceLow for a 1 hour period to specifically work in a 60 min timeframe rather than the last 60 entries?
Or maybe there is an easy way to pad the historical data where there are missing entries? If so, how would I go about that?
Thanks,
GJ