Issue with closing orders

Back to topics list To post a new topic, please log in or register
avatar
113
pontuso 2016.01.30 08:34
 

Has anyone run into the same problem?


I have 2 servers with one MT4 terminal each, both are identical and connected to the same broker.

The only difference is that one server is placed in London and the other one  in Sweden.

I have exactly the same setup on both servers, same EA, same amount of deposit.


My problem:

Yesterday my EA had one open order on each terminal.

The London Server closed the order 3 hours before, witch is wrong from my logic on the EA.

And the Swedish server closed the order as it should 3 hours later.


Troubleshooting:

I was thinking i might have made a mistake and started the wrong EA in London. So i tested the EA in strategy tester to see why it closed 3 hours before then the Swedish server.

But in strategy tester it worked as it should and closed the correct time (same time as Swedish server).


Probably you think that i have coded wrong in my EA, but since it's the exact one as on the Swedish servers with the exact setup it should not behave different.


So i was wondering if there is any function built in MT4 that can close all open orders at a certain time or something, i don't know? any clues?





avatar
2017
gooly 2016.01.30 09:23 #
 

It is practical impossible to help you without knowing the code!

1) What is the trigger to close the orders: Server time, local time, or GMT?

2) What is the time of the pc (vps): local time, London time, GMT ,..?

an so on!

avatar
113
pontuso 2016.01.30 11:02 #
 

Hi Gooly thanks for your time =)


VPS server time in london is Canada GMT-8

And i saw that allso the windows server clock confirmed this GMT-8 time, i assume that the last customer who used it might have been a canadian?


The order that was closed on the wrong time was closed - 29 Jan 00:00 GMT-0 (London time)

This is my time limited code that i suspect can be the issue. But i can't understand how? i mean TimeCurrent is what i know based on the time on chart, so it shouldn't be a issue with different VPS time? or am i wrong...

bool    Use_Time_Zone_1           = true;                          
bool    Use_Time_Zone_2           = true;                        
string  Time_Zone_2_Start         = "00:00";                      
string  Time_Zone_2_End           = "19:00";                     
bool    Close_Trades_on_Friday    = true;                         
string  Friday_Close_Time         = "19:30";    



//+------------------------------------------------------------------+


bool GoodTime()
  {
   if(CloseAllFriday())return(false);
   if(!Use_Time_Zone_1 && !Use_Time_Zone_2)return(true);
   if(Use_Time_Zone_1 && TimeDayOfWeek(TimeCurrent())>=0 && TimeDayOfWeek(TimeCurrent())<5)return(true);
   if(Use_Time_Zone_2 && TimeCurrent()>StrToTime(Time_Zone_2_Start) && TimeCurrent()<StrToTime(Time_Zone_2_End))return(true);
   return(false);  
  }


bool CloseAllFriday()
  {
   if(Close_Trades_on_Friday && TimeDayOfWeek(TimeCurrent())==5 && TimeCurrent()>=StrToTime(Friday_Close_Time))
      return(true); else return(false);
  }






Back to topics list  

To add comments, please log in or register