multi timeframe indicator

 

Hello, I have to create a multitimeframe indicator. My problem is to find iMA value for 5 different timeframe.


As here:

   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;   

   for(int i = limit-1; i >= 0; i--)
   {
        if (i >= MathMin(5000-1, rates_total-1-50)) continue;

        
     ima1=((iMA(Symbol(),1,20,0,MODE_EMA,PRICE_CLOSE,i+1)/Point/10);
     
//here I need to obtain others iMA of last bar (based on time of "i+1 one minute bar") for theese timeframe:
        ima2=((iMA(Symbol(),5,20,0,MODE_EMA,PRICE_CLOSE,??)/Point/10);
        ima3=((iMA(Symbol(),15,20,0,MODE_EMA,PRICE_CLOSE,??)/Point/10);
        ima4=((iMA(Symbol(),30,20,0,MODE_EMA,PRICE_CLOSE,??)/Point/10);
        ima5=((iMA(Symbol(),60,20,0,MODE_EMA,PRICE_CLOSE,??)/Point/10);

For example if i is 2000 I take i 2001 one minute bar, if, for example, if this 1min bar is time 01/07/2020 11:37, I need to take value 5minutes from 01/07/2020 11:35 bar, and so is for 15min bar(11:30), 30min bar(11:30), 1h bar (11:00).


Thank you

 
I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
 
  1. On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

  2. Don't mix apples and oranges.
Reason: