OrderSendAsync() problem with OnTradeTransaction() not firing

 

I have a problem using OrderSendAsync()

I have a test EA I made, it is generated from the wizard as a template and these handlers are added (see below)

It works.. what does "it works" mean? It means that the trade is placed, I get a retcode of TRADE_RETCODE_PLACED and then I get messages from OnTradeTransaction() on the Experts tab that culminate in a final one that displays the order #

However, my problem is that I have a much longer EA.. my actual EA that also calls OrderSendAsync() and the trade also is placed.. and the TRADE_RETCODE_PLACED is also received.

and the OnTradeTransaction() is exactly as written below. So the same in both EAs.

BUT... in my "real EA", it never fires. I get no Printed Order messages from OnTradeTransaction().

Just to be clear, the trade appears in the terminal - however - there is no subsequent firing of OnTradeTransaction() - so I'm stuck now, don't know how to proceed.

Can anyone think of anything that might cause this event not to fire?

The EA is still running because it can place trades again afterwards.. but they will also not show OnTradeTransaction() Print messages


int OnInit()

  {

//--- create timer

   EventSetTimer(60);

   

   //--- declare and initialize the trade request and result of trade request

   MqlTradeRequest request={0};

   MqlTradeResult  result={0};

//--- parameters of request

   request.action   =TRADE_ACTION_DEAL;                     // type of trade operation

   request.symbol   =Symbol();                              // symbol

   request.volume   =0.1;                                   // volume of 0.1 lot

   request.type     =ORDER_TYPE_BUY;                        // order type

   //request.price    =SymbolInfoDouble(Symbol(),SYMBOL_ASK); // price for opening

   request.deviation=5;                                     // allowed deviation from the price

   request.magic    =7;                          // MagicNumber of the order

   request.type_filling = ORDER_FILLING_IOC;

//--- send the request

   if(!OrderSendAsync(request,result))

      PrintFormat("OrderSend error %d",GetLastError());     // if unable to send the request, output the error code

//--- information about the operation

   PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);

   

//---

   return(INIT_SUCCEEDED);

  }



//+------------------------------------------------------------------+

//| TradeTransaction function                                        |

//+------------------------------------------------------------------+

void OnTradeTransaction(const MqlTradeTransaction& trans,

                        const MqlTradeRequest& request,

                        const MqlTradeResult& result)

  {

//---

   Print("OnTradeTransaction - Order: " + result.order);

    ENUM_TRADE_TRANSACTION_TYPE type=trans.type; 

    if (type == TRADE_TRANSACTION_ORDER_UPDATE) { 



            Print("Order: " + result.order);



    } else {

        

    }



  }