All you need is the M1 timeframe to compose any timeframe you want.
You start with the candle that has the time you want to start with.
You take the open of that candle.
Then you go forward and catch the highest high and the lowest low while you move towards the time where you want to end your candle.
Then you take the close of the candle at the end.
There you have your open, high, low and close for your time period of your desire.
A simple while loop will do the job for you.
I am working with the following array of ENUM_TIMEFRAMES elements:
Normally, PERIOD_M2 starts at 00:00 and continues to 00:02, 00:04 and so on. Also PERIOD_M3 starts at 00:00 and continues to 00:03, 00:06 and so on. The other timeframes follow in a similar manner.
I am trying to figure out how to shift the starting times for the above ENUM_TIMEFRAMES elements so that with a shift of -1 minute
PERIOD_M2 starts at 23:59 and continues to 00:01, 00:0 and so on. Also PERIOD_M3 starts at 23:59 and continues to 00:02, 00:05 and so on.
also for a shift of 1 minute
PERIOD_M2 starts at 00:01 and continues to 00:03, 00:03 and so on. Also PERIOD_M3 starts at 00:01 and continues to 00:04, 00:07 and so on.
and other timeframes follow suit.
I am using this array to compare Open, High, Low and Close of various candlesticks. Below is an example of how I am using the array to compare highs of two candles from two timeframes: