In different currency pairs, the function ibarshift has different results

 

hello friend , Recently, I encountered a very confused problem.

   int year = TimeYear(TimeCurrent());

   int month = TimeMonth(TimeCurrent());

   int day = TimeDay(TimeCurrent());

   string s = (string)year + "." +(string)month + "."+(string)day + " " + (string)00+":00";

   datetime firstBarTm = StringToTime(s);

   int firstBarNum = iBarShift(NULL,0,firstBarTm); 

In the above code, for example, in a 1-hour chart, On the first candle, at 00:00 When in currency pair “XAUUSD” , firstBarNum  return 1, but in  currency pair “EURUSD” , firstBarNum  return 0 , why  ?

 

 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  2. Your code
     int year = TimeYear(TimeCurrent());
    
       int month = TimeMonth(TimeCurrent());
    
       int day = TimeDay(TimeCurrent());
    
       string s = (string)year + "." +(string)month + "."+(string)day + " " + (string)00+":00";
    
       datetime firstBarTm = StringToTime(s);
    Simplified
    datetime firstBarTm = date();
              date/time (2017)
              Find bar of the same time one day ago - MQL4 programming forum (2017)
  3. Xiaolei Liu: When in currency pair “XAUUSD” , firstBarNum  return 1, but in  currency pair “EURUSD” , firstBarNum  return 0 , why  ?

    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 (2019)

 
thanks , over .i have been solve this problem already.
Reason: