Expert Advisor - Trade Messages Not Printing - Trade Actions

 

Hello, MQL5 Community

Could you please assist me with the following inquiry concerning my EA's messaging problem, as shown below:

Journal Entry


The EA does not print the reason for the trade not being opened, and vice versa.

The "Journal" does not print trade outputs based on the sequence of events.


I have highlighted the trade outputs inside the code for visual reference as well

Sample of what I intend to see e.g.: 2022-11-07 12:59 BUY Order Executed Successfully

I would appreciate it if you could assist me with this matter. EA code provided for reference
//+------------------------------------------------------------------+
//|                   Entry Function                                         |
//+------------------------------------------------------------------+
   if(Hour() == StartHour)
     {
      comment = GetDateAndTime();
      if(OpenBar == true)
        {
         OpenBar = false;
         //FindTicket makes sure that the EA will pick up its orders
         //even if it is relaunched
         ticket = FindTicket(Magic);
         
         bool res;
         res = OrderSelect(ticket, SELECT_BY_TICKET);
         if(res == true)
         {
            if(OrderCloseTime() == 0)
            {
               bool res2;
               res2 = OrderClose(ticket, OrderLots(), OrderClosePrice(), 10);
               
               if(res2 == false)
               {
                  Alert("Error Closing Order #", ticket);
               }
            } 
         }
      
         if(Open[0] < Open[StartHour] - MinPipLimit*MyPoint) //v3.0
         {
            // Buy entry
            if(Open[0] > MABuy || !MAFilter || !CCIFilter) // Entry Method selection from global variable settings
              {
               //here we are assuming that the TakeProfit and StopLoss are entered in Pips
               ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, vSlippage, Bid - StopLoss * vPoint, Bid + TakeProfit * vPoint, "Set by Process Expert Advisor", Magic, 0, Blue);
               if(ticket < 0)
                 {
                  comment = comment + " " + "Error Sending BUY Order";
                 }
               else
                 {
                  comment = comment + " " + "BUY Order Executed Succesfuly";
                 }
              }
            else
              {
               comment = comment + " " + "Reason Order Not Opened: MA Filter Not Passed";
            }
         }
         else if(Open[1] > Open[StartHour] + MinPipLimit * MyPoint) //v3.0
              {
               //---------------------------------
               // Sell entry
               if(MASellFilter && CCISellFilter)
                 {
                  //here we are assuming that the TakeProfit and StopLoss are entered in Pips
                  ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, vSlippage, Ask + StopLoss * vPoint, Ask - TakeProfit * vPoint, "Set by Process Expert Advisor", Magic, 0, Blue);
                  if(ticket < 0)
               {
                  comment = comment + " " + "Error Sending SELL Order";
               }
               else
               {
                  comment = comment + " " + "SELL Order Executed Succesfuly";
               }                  
            }
            else
            {
               comment = comment + " " + "Reason Order Not Opened: MA Filter Not Passed";
            }
         }
         else
         {
            comment = comment + " " + "Reason Order Not Opened: MinPipLimit Filter Not Passed";
         }
         myAlert("EA", comment);
        }
      Comment(comment);
      Print(comment);
     }
   return;
  }
 
OTMT Howard: Hello, MQL5 Community Could you please assist me with the following inquiry concerning my EA's messaging problem, as shown below: Journal Entry The EA does not print the reason for the trade not being opened, and vice versa. The "Journal" does not print trade outputs based on the sequence of events. I have highlighted the trade outputs inside the code for visual reference as well Sample of what I intend to see e.g.: 2022-11-07 12:59 BUY Order Executed SuccessfullyI would appreciate it if you could assist me with this matter. EA code provided for reference

There are two logs when running an EA live. Output from Prints in an EA will appear in the "Experts" log and not in the "Journal".

Only in the Strategy Tester does Prints appear in the tester's Journal.

 
Fernando Carreiro #:

There are two logs when running an EA live. Output from Prints in an EA will appear in the "Experts" log and not in the "Journal".

Only in the Strategy Tester does Prints appear in the tester's Journal.

Hei, Fernando Carreiro

Thanks for the heads-up:

Would it be possible to have it print messages as mentioned earlier?

The Experts and Journal tabs do not show any information related to the experts' comments.

 
OTMT Howard #: Hei, Fernando Carreiro. Thanks for the heads-up: Would it be possible to have it print messages as mentioned earlier? The Experts and Journal tabs do not show any information related to the experts' comments.

If it is not printing in the Experts tab, then there are bugs in your code (probably in other sections) that is preventing the print from occurring.

Use MetaEditor's debugger to follow the flow of the code and find out why.

 
Fernando Carreiro #:

If it is not printing in the Experts tab, then there are bugs in your code (probably in other sections) that is preventing the print from occurring.

Use MetaEditor's debugger to follow the flow of the code and find out why.

Thanks, will do that