Use an other timezone timestamp, then where I or my broker is located.

 

Hello,

I want to trade baised on the USA Eastern times. But my broker is located somewhere else, so it doesn't have the same timzone as USA Eastern.

How can I code something that it check what time it is at USA Eastern and it trades for lets say at 9:00am USA Eastern time? Also it needs to work with summer and wintertime (Daylight Saving).

Anyone who can help me with this?

 
I do not think it is possible in MQL. I would use the SystemTimeToTzSpecificLocalTime from Kernel32.dll to obtain the ET zone, or alternatively you may code custom calculation based on TimeLocal().
 
My code computes broker's TZ offset to UTC (TimeGMT(),) and isNYDST()
 

Well I found this code https://www.mql5.com/en/code/9201 but because of the daylight saving it is not going to work or I need to change it everytime the time will set 1 hour back or forward.

WHRoeder I also tried your code but when I compile it I get some errors:

'now.srv' - expression on global scope not allowed      C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (210, 5)
'now.utc' - expression on global scope not allowed      C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (211, 5)
'TimeGMT' - expression on global scope not allowed      C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (211, 15)
'now.srv' - expression on global scope not allowed      C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (211, 23)
'now.srv' - expression on global scope not allowed      C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (212, 9)
'mkt.closes.srv' - expression on global scope not allowed       C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (212, 19)
'Srvr.To.UTC.Auto' - variable not defined       C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (236, 13)
'Srvr.To.UTC.Hours' - variable not defined      C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (240, 13)
'Srvr.To.UTC.Hours' - variable not defined      C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (242, 26)
'Srvr.To.UTC.Hours' - variable not defined      C:\Program Files (x86)\Excel Markets - Metatrader\experts\EA.mq4 (245, 23)

When I got this starting code where do I need to place your code to get it working?

//+------------------------------------------------------------------+
//|                                                         EA2.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Thx

 
fabje:

... but because of the daylight saving it is not going to work or I need to change it everytime the time will set 1 hour back or forward.

See my code for calculating the start/end dates for American DST and European DST.
 
fabje WHRoeder I also tried your code but when I compile it I get some errors: .. where do I need to place your code

You don't. You have to understand the code. ALL the code.

Did you download the original code attached (Not the corrections/additions?) Where and what is now.srv and did you add that? No you didn't, Srvr.To.UTC.Hours is an external, so I know you didn't. "Expression on global scope" means you did even paste the code into a function.

This is basic coding. VERY basic. Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem. Non-Compiling code is NO attempt at all.

Reason: