Orders open strange behavior

 

Hello,

I have an EA that open #3 orders after candle close (if some conditions are true). The issue is that the orders are opened after 10 minutes from candle closing (see attached screenshot of Journal and chart). The orders should be opened at 4:30:00 instead of 4:40:00 

Can you help me to understand why it happened?

Thanks

Giovanni

void esecuzioneStrategiaBuy(){

   double valSL = 0;
   
   int CandelaLow = iLowest(NULL,0,MODE_LOW,2,1); 
       
   valSL   = (1 + iLow(NULL,0,CandelaLow) - 1 - (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)
   
   // BUY Ordine 1
   ticket1 = OrderSend(Symbol(),OP_BUY,volume,Ask,0,valSL,0," Buy ordine #1 ",0,0,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,0,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,0,clrCrimson); 
   if (ticket3 < 0) stampa("Errore in apertura Buy ordine #3 ", GetLastError());
    
     
}
Files:
 
elfunambolo: The orders should be opened at 4:30:00 instead of 4:40:00
  1. Your clock vs your brokers is off by 10 minutes.
  2.  valSL   = (1 + iLow(NULL,0,CandelaLow) - 1 - (MODE_SPREAD / 10) ); 
    
    Mode spread is a constant, an enumeration to be used in market info.

    MODE_SPREAD

    13

    Spread value in points


    what do you think 13/10 is?. What do you think the candle low - 1 is. Bogus except on for JPY pairs and that chart.

  3. if ((Close[1]- valSL) > 3 ) return;   //se SL > 30 pips
    That's not 30 pips. That's not 30 points. That is 3. Bogus except on that chart. You are not adjusting SL, TP, and slippage; for 4/5 digit brokers and for JPY pairs. For metals try: How to manage JPY pairs with parameters? - MQL4 and MetaTrader 4 - MQL4 programming forum (Item 3) #3
  4. You must RefreshRates between server calls.
 
whroeder1:
  1. Your clock vs your brokers is off by 10 minutes.
  2. Mode spread is a constant, an enumeration to be used in market info.

    MODE_SPREAD

    13

    Spread value in points


    what do you think 13/10 is?. What do you think the candle low - 1 is. Bogus except on for JPY pairs and that chart.

  3. That's not 30 pips. That's not 30 points. That is 3. Bogus except on that chart. You are not adjusting SL, TP, and slippage; for 4/5 digit brokers and for JPY pairs. For metals try: How to manage JPY pairs with parameters? - MQL4 and MetaTrader 4 - MQL4 programming forum (Item 3) #3
  4. You must RefreshRates between server calls.

1. How can I check if I have 10 minutes of shift between clocks? I checked with broker and it has same time of my Market watch
Files:
Reason: