iHigh(_Symbol,PERIOD_D1,0) gives me Past Day result

 
void OnTick()
  {
//---
   Download_News();
   if(TimeGMT() == StringToTime("18:50") )
     {
      double range_day = iHigh(_Symbol,PERIOD_D1,0) - iLow(_Symbol,PERIOD_D1,0);
      double range_3h = iHigh(_Symbol,PERIOD_H1,(iHighest(_Symbol,PERIOD_H1,MODE_HIGH,3,0))) - iLow(_Symbol,PERIOD_H1,iLowest(_Symbol,PERIOD_H1,MODE_LOW,3,0));
      double range_1h = iHigh(_Symbol,PERIOD_H1,0) - iLow(_Symbol,PERIOD_H1,0);
      long volumes_4h = iVolume(_Symbol,PERIOD_H4,0);



      SendNotification("Daily Range: " + DoubleToString(range_day * 10000,0) + " pips\nRange 3h: "+ DoubleToString(range_3h * 10000,0) + " pips\nRange 1h: " + DoubleToString(range_1h * 10000,0) + " pips\nLots traded last 4h: " + IntegerToString(volumes_4h));
      Print("Notification Sent!");
     }
  }


This code run one time at 18:50 gmt time. Every single day all the values are not correct.

 range_day gives me always the past day range. 

How thats even possible?

Documentation on MQL5: Network Functions / SendNotification
Documentation on MQL5: Network Functions / SendNotification
  • www.mql5.com
SendNotification - Network Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
arimbur: This code run one time at 18:50 gmt time. Every single day all the values are not correct. Range_day gives me always the past day range. How thats even possible?

You are assuming that your Broker's trade server is using GMT time-zone. That may not be the case.

Find your broker's time-zone first, and consider what the starting GMT time is for the current bar as per your broker's time-zone.

 
  1. Please edit your (original) post and use the CODE button (or 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. double range_day = iHigh(_Symbol,PERIOD_D1,0) - iLow(_Symbol,PERIOD_D1,0); 

    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)


Reason: