Download MetaTrader 5

EA missing some trades, what could be wrong?

To add comments, please log in or register
Gabriel Viali
Gabriel Viali 2015.03.07 22:34 

Hello guys.

I recently seen that the simple EA i've done to open trades when a custom indicator plots an arrow has been missing some trades.

I've configured the indicator to give a lot of alerts, exactly for testing the functioning of the EA , and from like 10 signals the indicator gave, the EA opened only 7, its not a pattern, but its missing a significant ammount of oportunities.

I really can't see why this is happening, and the GetLastError() do not return me any information about this missing trades. Could it be the some problem with the broker? 

The  source code for it is in this post:

Thanks in advance. 

whroeder1 2015.03.08 02:15  
gviali: I really can't see why this is happening, a
      order=OrderSend(Symbol(),OP_BUY,lots,Ask,0,0,0,"custom buy arrow",magicnumber,0,Blue);
         Print("Error Opening Buy Order: ",GetLastError());

  1. Because you don't Check your return codes (OrderSend)
    Returns number of the ticket assigned to the order by the trade server or -1 if it fails.
    What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  2. To late to call GetLastError, you've already called sleep and possibly destroyed the value.
  3. Don't double post
Gabriel Viali
Gabriel Viali 2015.03.08 20:28  

WHRoeder, i've took it out  the Sleep function. It was making the EA opens new orders when the Sleep time runned over.

So this should work to inform why it's not opening the order, right?

     Print("Order OK");
     Print("Order not OK:", GetLastError());


Thanks for your response! And sorry for the double post, I just toth that old one was pratically dead.

To add comments, please log in or register