EA closing trades wrong on live account but not in backtest and on other broker

 

Hi

On one of my live account

All my open trades are closing 00:00:00 on Fridays

I can't find the reason why they are closing because they are not closing on backtest and on other livebrokers i have.


The thing that are the difference between the brokes is that:

-The one that are closing the orders the chart time is GMT+1.

- And the one that are correct and not closing the orders are in GMT+0.


And another thing that are different is the:

-The VPS server of the EA/terminal who are closing the orders is GMT+8.

-And the VPS server of the EA/terminal who is not closing the orders are GMT+0.


Can the difference in VPS server time be doing this (based on my code below)?

Or have anyone have another clue what might cause this problem?


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



//+------------------------------------------------------------------+
//| Time limited trading                                             |
//+------------------------------------------------------------------+
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);
  }
//+------------------------------------------------------------------+
//| Time limited trading                                             |
//+------------------------------------------------------------------+
 
olzonpon:

Don't use StrToTime as it returns the date as local time, not platform time if the date is not included in the string.

 
Keith Watford:

Don't use StrToTime as it returns the date as local time, not platform time if the date is not included in the string.

Thank you =)