Trade line not executed

 

I have alerts that display details of an executed trade once the trade line has been executed.  Problem is, the alerts display but the trade is not executed.  So the criteria for the trade is met an and the trade is not executed but the alert line is.  This EA has worked in the past and the trade lines have not changed since so the trade lines are legit.  What could be the problem?

if(Bid >= High[h] + 1*Point)
      {
         if(SL > 0)
            sl = Low[l];
         if(TP > 0)
            tp = Ask + (High[h] - Low[l]);
         if(BrokerECN)
         {
            iTicket = OrderSend(Symbol(), OP_BUY, GetLots(SL), Ask, Slippage, 0, 0, "", MagicNumber, 0, Blue);
            if(iTicket > 0)
            {
               OrderModify(iTicket, OrderOpenPrice(), sl, tp, 0, CLR_NONE);
            }
                      
         }
         else
         {
            OrderSend(Symbol(), OP_BUY, GetLots(SL), Ask, Slippage, sl, tp, "", MagicNumber, 0, Blue);
         }
         
                 
         lasttrade = Time[0];
         SLMoved = 0;
         
         Alert(Symbol(),"* Price: ", Ask," SL: ",sl," TP: ",tp);
         Alert(Symbol(),"MikeCF_4.2 DD:HH:MM  ",DayOfWeek(),":",Hour(),":",Minute()," Buy ", GetLots(SL) ," Lots");
 
bluesman:

I have alerts that display details of an executed trade once the trade line has been executed.  Problem is, the alerts display but the trade is not executed.  So the criteria for the trade is met an and the trade is not executed but the alert line is.  This EA has worked in the past and the trade lines have not changed since so the trade lines are legit.  What could be the problem?

Perhaps you should test the return values from your OrderSend() calls and if they have failed you can find what the error was and print all the relevant information to the log.  Then when it fails you will have all thee necessary information to determine the cause of the failure . . .

 

Read this:  What are Function return values ? How do I use them ?

 
bluesman: This EA has worked in the past and the trade lines have not changed since so the trade lines are legit.  What could be the problem?
  1. Just because it worked previously and you didn't change them doesn't mean there were no problems with the code. It means you didn't see any before. Never assume.

  2. iTicket = OrderSend(Symbol(), ...
    if (iTicket > 0) ...
    Check your return codes (OrderSend, OrderModify) What are Function return values ? How do I use them ? - MQL4 forum So you find out WHY they've stopped working.
  3. Add print statements so you find out if you are even TRYING to open.
    Print("Bid=",PriceToStr(Bid)," High[",h,"]=",PriceToStr(High[h])," B>H=="
       Bid >= High[h] + 1*Point);
    if(Bid >= High[h] + 1*Point) ..
string   PriceToStr(double p){   return( DoubleToStr(p, Digits) );            }
 
RaptorUK:

Perhaps you should test the return values from your OrderSend() calls and if they have failed you can find what the error was and print all the relevant information to the log.  Then when it fails you will have all thee necessary information to determine the cause of the failure . . .

 

Read this:  What are Function return values ? How do I use them ?

But there would be no return code because the line does not execute...That is the problem.  It's not a failed entry, it's like the OrderSend(Symbol(). OP_BUY etc line isn't even there....
 
bluesman:
But there would be no return code because the line does not execute...That is the problem.  It's not a failed entry, it's like the OrderSend(Symbol(). OP_BUY etc line isn't even there....

And if the line was executed and there was a return code you want to ignore it ? 

What do you have in the log ? is Allow Live Trading enabled ?

 
bluesman: But there would be no return code because the line does not execute...That is the problem. 
Answered in #3
Reason: