Last Activity Time of EA
GV_LastTime = (int) TimeCurrent() : Time_Difference = TimeCurrent() - (DateTime) GV_LastTime;
Thanks for the hint.
Also, what does it mean that the TimeCurrent() function returns the Server time ?
does that mean it's possible for the EA to make mistakes in time difference calculation, once the broker is changed ?
just asking outa curiosity.
-
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.
Checking for Market Closed - Expert Advisors and MQL5 programming forum Trading - MQL5 programming forum
Swap is computed 5pm ET. No swap if no open orders at that time. 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 NYs. 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.
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.
- If you search the web you will find differing answers. Those are all wrong (half the year) because they do not take DST into account (or that it changed in 2007 [important when testing history.])
Hi, writing my first EA, which is also my first try in MQL language.
Have been programming in other languages for a few years now.
The question is : How I can calculate the time difference, since the last time my EA was used ?
let's say , I don't want the EA to start , if it's less than 12 hours since its last activity.
I've decided this (based on what I read in Documents and some forum search) :
(which is strange but probably doable, cuz you gotta retrieve that timedate type and save it in a double variable. and then compare it against another timedate variable !)
I know timedate variables are nothing more than a number of seconds from a special time. but is the following the way to do the third step ?
Time_Difference = timedate CurrentTimeNow - double GV_LastTime
Please someone comment on how to do it? specially the third step.
and if there's a better approach, please