Scripts: Check trading day end is reached

 

Check trading day end is reached:

This script will detect an end-of-trading day and notify

Author: Biswarup Banerjee

 
This is totally wrong!
 
why do you say it is wrong? what part seems wrong to you?
 
Не каждый день заканчивается в 23:59 Ваше решение не верное.
 

New here, Need a clarification. It takes system time right? not the trading end of the day zone. 

Assume Trading works in GMT, but system time is different time zone, it won't stop at wrong time?

 
  1. Dhayal Ram #:

    New here, Need a clarification. It takes system time right? not the trading end of the day zone. 

    Assume Trading works in GMT, but system time is different time zone, it won't stop at wrong time?

    TimeCurrent is chart time. There is no asumption.

  2.    datetime dCurrentTime = TimeCurrent();
       datetime time_tradeend = StrToTime(TimeToStr(TimeCurrent(),TIME_DATE) + " "  + "23:59");
       return dCurrentTime>=time_tradeend; 
    However, unless you get a tick in the last minute of the day, the code fails.

  3. Don't use strings, just do the numerical calculation.

    static datetime curDate=0; datetime preDate=curDate; curDate=date();
    bool isNewDay = curDate != prevDate;
    ⋮
              Find bar of the same time one day ago - MQL4 programming forum #1 & #6 (2017)

    See also Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
    Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
    MQL5 Programming Basics: Time - MQL5 Articles (2013.04.26)

 
Biswarup Banerjee #:
why do you say it is wrong? what part seems wrong to you?

You assume that ALL Fx brokers end their trading day at 23:59, which is not true.

The Fx day actually ends on 23:59 only on GMT+2 brokers. Other brokers have different times, for example exness ends on 20:59.

 
amrali #:

You assume that ALL Fx brokers end their trading day at 23:59, which is not true.

The Fx day actually ends on 23:59 only on GMT+2 brokers. Other brokers have different times, for example exness ends on 20:59.

then I think it would be better if we take the end time as input. 

Reason: