Download MetaTrader 5

how to calculate seconds after market_open ?

To add comments, please log in or register
selnomeria
254
selnomeria  

In other platforms, there is an eaasy way to calculate time remianinig till market close, or time passed after market_open...


how to do with mql4?

whroeder1
16764
whroeder1  

You need to convert GMT time to NY time. And compare that to Friday 5PM or when your broker closes.

Posted starting my code Why is there NO Complete EA within the Code-Base? - MQL4 forum with market close time a few posts down.

That code has not been adjusted for Build 600+. Specifically dots in variable names, and TimeGMT is now built in, so it and LocalTimeGMT can be deleted.

  1. FX opens 5pm ET Sunday and ends 5pm ET Friday. Some brokers start after (6pm is common/end before (up to 15 minutes) due to low volatility.

    Swap is computed 5pm ET. No swap if no open orders at that time.


  2. Brokers use a variety of timezones. Their local time (with or without DST,) GMT/UTC, GMT+2, NY+7.

    Only with NY+7 does the broker's 00:00 equals 5pm ET and the start of a daily bar is the start of a new FX day.

    GMT brokers, means there is a 1 or 2 hour D1/H4 bar on Sunday (depending on NY DST,) and a short Friday bar.

    GMT+2 is close but doesn't adjust for NY DST. 

    EET is closer except when their DST doesn't match NY's. Last Sunday of March and 1:00 on the last Sunday of October vs second Sunday in March and return at 2:00 a.m. EDT to 1:00 a.m. EST on the first Sunday in November.

  3. Non-NY+7, means the chart daily bar overlaps the start, and converting broker time to NY time requires broker to GMT to NY timezone conversions.


  4. If you search the web you will find differing answers. Those are all wrong (half the year) because they do not take NY DST into account (or that it changed in 2007 [important when testing history.])
selnomeria
254
selnomeria  

Sorry,  I mean day's market-open and market-close times  (session end and start) to get automatically.

for example:


if (Time[i] == SessionStartTime(Today) )


or like this, is there?

Alain Verleyen
Moderator
34405
Alain Verleyen  
selnomeria:

Sorry,  I mean day's market-open and market-close times  (session end and start) to get automatically.

for example:


if (Time[i] == SessionStartTime(Today) )


or like this, is there?

Not possible with MT4. Try MT5.
selnomeria
254
selnomeria  
Alain Verleyen:
Not possible with MT4. Try MT5.

and I am so much surprised... How guys you check if market has started??? it's insane, should be so simple ?!!
Keith Watford
Moderator
10536
Keith Watford  

Please do not double post.

I have deleted your other topic.

whroeder1
16764
whroeder1  
selnomeria: How guys you check if market has started??? it's insane, should be so simple ?!!
If OnTick gets called, the market has started!
To add comments, please log in or register