Download MetaTrader 5

EA strange behavior in DEMO vs Backtest

To add comments, please log in or register
elfunambolo
106
elfunambolo  

Hello,

I created my EA that open #3 orders at the same time when some conditions are true. In backtesting EA works fine and in Result I can see my #3 order with same open time:

The issue is in DEMO. I see in Journal tab a time delay (seconds, until 1 minute) between Order Buy Market and Order Opened time:


I see also in Account History the order's opened time different vs what I see in the Journal tab:


Why this behavior happened?


Thanks or help,

Giovanni

Alain Verleyen
Moderator
33815
Alain Verleyen  

On a live account (demo or real) you always have a delay between order request and server answer. Usually with a demo account is a little delay (<1sec).

The time your are seeing in Journal (Time column) is local time (your computer). Account history shows server (broker) time.

elfunambolo
106
elfunambolo  
Alain Verleyen:

On a live account (demo or real) you always have a delay between order request and server answer. Usually with a demo account is a little delay (<1sec).

The time your are seeing in Journal (Time column) is local time (your computer). Account history shows server (broker) time.


Seconds are ok, but I see that the #3 orders are separated by minutes (17:00, 17:01, 17:02). Maybe the cause is the long ping with server? 

I see this message in Journal:


 This is the code of my function where I send the orders:


void esecuzioneStrategiaBuy(){

   double valSL = 0;
   
   int CandelaLow = iLowest(NULL,0,MODE_LOW,2,1); 
       
   valSL   = ( iLow(NULL,0,CandelaLow) - (MODE_SPREAD / 10) );   //Stop loss si posiziona sotto il minimo delle candele (1,2) -10 pips – spread actual
  
   if ((Close[1]- valSL) > 3 ) return;   //se SL > 30 pips no esecuzione ordini (invece del return aggiungere BUYSTOP)
   
   datetime scadenza = orarioRiferimento + cancellazioneScadenza;
                  
   
   // BUY Ordine 1
   ticket1 = OrderSend(Symbol(),OP_BUY,volume,Ask,0,valSL,0," Buy ordine #1 ",0,scadenza,clrCrimson); 
   if (ticket1 < 0) stampa("Errore in apertura Buy ordine #1 ", GetLastError());
             
        TPticket1 = (High[1] - Low[1]) + High[1];
   
   // BUY Ordine 2
    ticket2 = OrderSend(Symbol(),OP_BUY,volume,Ask,0,valSL,0," Buy ordine #2 ",0,scadenza,clrCrimson); 
    if (ticket2 < 0) stampa("Errore in apertura Buy ordine #2 ", GetLastError());
     
   
   // BUY Ordine 3
   ticket3 = OrderSend(Symbol(),OP_BUY,volume,Ask,0,valSL,0," Buy ordine #3 ",0,scadenza,clrCrimson); 
   if (ticket3 < 0) stampa("Errore in apertura Buy ordine #3 ", GetLastError());
    
     
}
whroeder1
16575
whroeder1  
elfunambolo: Seconds are ok, but I see that the #3 orders are separated by minutes (17:00, 17:01, 17:02). Maybe the cause is the long ping with server?
  1. Could be a number of causes. A network timeout/reconnect can take a minute. During news release it can take several minutes to open an order. Your image shows it switched servers during your time period.
  2. Opening orders takes time, you must RefreshRates between server calls if you want to use any Predefined Variables - MQL4 Reference
  3. You don't have to open three orders, you can open one and do partial closes your various TPs.
To add comments, please log in or register