How to get details of candlesticks from all timeframes?

 

I declare arrays open,high, low and close and use copyopen to copyclose to get details of previous candles.

I dont declare ontick() but use OnTimer() with a timer value same as timeframe of chart. this helps me get these details of any number of previous candles.

Now suppose i am working in 15m with ontimer interval as 900seconds. I will have readily available data of any number of previous candles of this timeframe. But how should i get these details of candles from higher timeframes?


one way i think is to check for x times higher tf is to mathematically calculate it from the candle details i have but it seems cumbersome and there must be a simple way.


Any help or code snippet anyone has will be helpful...thanks.

 
  1. Saurabh Suman: I dont declare ontick() but use OnTimer() with a timer value same as timeframe of chart. this helps me get

    This will help you lose as the timer and start of a new bar drift. Just check for a new bar.

    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              MT4: New candle - MQL4 programming forum #3 (2014)
              MT5: Accessing variables - MQL4 programming forum #3 (2022)

    I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum (2011)

  2. Saurabh Suman: But how should i get these details of candles from higher timeframes?

    Write a new bar code for multiple timeframes and just get them.

    detecting a new bar without removing ability to detect tick in multiple timeframe - Easy Trading Strategy - MQL4 programming forum #8 (2021.08.24)