Problem With Repainting data when I try to catch data from another Timeframe

mohammad shajary  

Hello, I try to get data ( a value of a moving from another M5 ) and use it with data in Current time frame but it has repaint 

please help me to solve the problem

 double moving_val_M1 = 0 , moving_val_M5 = 0;
 for(int i = candles; i>=0; i--)  // Bars-1
         int m1 = iBarShift(NULL, PERIOD_M1, iTime(NULL, PERIOD_M1, i), true);
         int m5 = iBarShift(NULL, PERIOD_M5, iTime(NULL, PERIOD_M5, i), true);

          moving_val_M1 = iMA(NULL,PERIOD_M1,100,0, MODE_EMA, PRICE_MEDIAN, m1);

          moving_val_M5 = iMA(NULL,PERIOD_M5 , 60 , 0 , MODE_EMA, PRICE_MEDIAN,m5 );


values that are catching from M5 time frame after my conditions will show correctly but after closing each candle, some of them will disappear 

William Roeder  
  1. moving_val_M1 = iMA(NULL,PERIOD_M1,100,0, MODE_EMA, PRICE_MEDIAN, m1);

    Why did you post your MT4 question in the MT5 Indicators section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2.         int m1 = iBarShift(NULL, PERIOD_M1, iTime(NULL, PERIOD_M1, i), true);
    M1 always equals i. You are comparing apples to apples.

              Don't mix apples and oranges.

  3. 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 - MQL4 programming forum - Page 3 #26.4 (2019)