EA missing some trades, what could be wrong?

Back to topics list To post a new topic, please log in or register
avatar
16
gviali 2015.03.07 23: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: https://forum.mql4.com/66623/page2

Thanks in advance. 

avatar
13001
WHRoeder 2015.03.08 03: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);
      Sleep(sleep);
      if(order==0)
        {
         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
avatar
16
gviali 2015.03.08 21: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?

if(order>0)
    {
     Print("Order OK");
    }
 else
    {
     Print("Order not OK:", GetLastError());
    }

 

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

 

Back to topics list  

To add comments, please log in or register