Nothing was printed in Journal, yet the EA still placed the order for me?

 

I'd like to post an image but not sure how, words would still be enough to understand my problem thought.

So here is the problem:

I print information when conditions are met, but sometimes the EA would skip some dates and not print anything, yet it'd still place order in those dates.

In my situation, it did not print the information between 2022.12.03 to 2022.12.14.

Yet, orders were still placed.

This has happened a few times already but I did not pay it with much attentions, until now, it has placed orders without following the logic of my codes.

Below is a snippet of my codes, I used Print() and not everything was printed during the testing period (2022,12.01 to 2022.12.31)

   double currentbar_EMA8_5M = iMA(_Symbol, 5, 8, 0, 1, 0, 1);
   double currentbar_EMA13_5M = iMA(_Symbol, 5, 13, 0, 1, 0, 1);
   double currentbar_EMA21_5M = iMA(_Symbol, 5, 21, 0, 1, 0, 1);
   double previousbar_EMA8_5M = iMA(_Symbol, 5, 8, 0, 1, 0, 2);
   double previousbar_EMA13_5M = iMA(_Symbol, 5, 13, 0, 1, 0, 2);
   double previousbar_EMA21_5M = iMA(_Symbol, 5, 21, 0, 1, 0, 2);
   double currentbar_ENV_UPPER_5M = iEnvelopes(_Symbol, 5, 20, 1, 0, 0, 0.24, MODE_UPPER, 1);
   double currentbar_ENV_LOWER_5M = iEnvelopes(_Symbol, 5, 20, 1, 0, 0, 0.24, MODE_LOWER, 1);
   double ENV_AVG_5M = (currentbar_ENV_LOWER_5M + currentbar_ENV_LOWER_5M)/2;
   double currentcandlestick_closed_5M = iClose(_Symbol, 5, 1);

if(currentbar_EMA8_5M > currentbar_EMA13_5M &&
   currentbar_EMA8_5M > currentbar_EMA21_5M &&
   currentbar_EMA13_5M > currentbar_EMA21_5M && 
   currentcandlestick_closed_5M < ENV_AVG_5M &&
   OrdersTotal()==0)                                                  //buy signal
   {
      Print("currentcandlestick_closed_5M: ", currentcandlestick_closed_5M);
      Print("ENV_AVG_5M: ", ENV_AVG_5M);
      if(previousbar_EMA21_5M > previousbar_EMA8_5M ||
      previousbar_EMA21_5M > previousbar_EMA13_5M ||
      previousbar_EMA13_5M > previousbar_EMA8_5M)                    //check previous bars if they're giving reverse (sell) signal
      {
         OrderSend(_Symbol, 0, 1, Ask, 100, 0, 0);        //Long
      }                    
   }                   
   
   if(currentbar_EMA8_5M < currentbar_EMA13_5M &&
   currentbar_EMA8_5M < currentbar_EMA21_5M &&
   currentbar_EMA13_5M < currentbar_EMA21_5M &&
   currentcandlestick_closed_5M > ENV_AVG_5M &&
   OrdersTotal()==0)                                                  //sell signal
   {
      Print("currentcandlestick_closed_5M: ", currentcandlestick_closed_5M);
      Print("ENV_AVG_5M: ", ENV_AVG_5M);
      if(previousbar_EMA21_5M < previousbar_EMA8_5M ||
      previousbar_EMA21_5M < previousbar_EMA13_5M ||
      previousbar_EMA13_5M < previousbar_EMA8_5M)                    //check previous bars if they're giving reverse (buy) signal
      {
         OrderSend(_Symbol, 1, 1, Bid, 100, 0, 0);        //Short
      }                    
   }   
 

Forum on trading, automated trading systems and testing trading strategies

General rules and best practices of the Forum.

Alain Verleyen, 2023.03.28 20:04

Please don't post randomly in any section. Your question is not related to the section you posted.

MT4/mql4 has it's own section on the forum.

I have moved your topic to the correct section.