Help understanding Tester Journal

 

Hello,

I'm new to trading, but with years of experience in programming.

However, I can't understand some messages I get in journal.

I got the code for the new bar from https://www.mql5.com/en/articles/159

Here's the code I'm testing, a simple EMA crossing script:

#include <Trade\Trade.mqh>

#define _SLOW 100
#define _FAST 50

CTrade trade;
int maSlowHandler;
int maFastHandler;
long lastTime=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseAllPositions()
  {
   while(PositionsTotal()>0)
     {
      trade.PositionClose(PositionGetTicket(0));
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool isNewBar()
  {
   long lastbarTime=SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE);
   if(lastTime==0)
     {
      lastTime=lastbarTime;
      return(false);
     }
   if(lastTime!=lastbarTime)
     {
      lastTime=lastbarTime;
      return(true);
     }
   return(false);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   PrintFormat("OnInit: %s",TimeToString(TimeCurrent(),TIME_SECONDS));
   maSlowHandler=iMA(_Symbol,_Period,_SLOW,0,MODE_EMA,PRICE_CLOSE);
   maFastHandler=iMA(_Symbol,_Period,_FAST,0,MODE_EMA,PRICE_CLOSE);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   PrintFormat("OnDeinit: %s",TimeToString(TimeCurrent(),TIME_SECONDS));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   double maSlow[3];
   double maFast[3];

   CopyBuffer(maSlowHandler,0,0,3,maSlow);
   CopyBuffer(maFastHandler,0,0,3,maFast);

   if(isNewBar())
     {
      if(PositionsTotal()>0 && maFast[1]<maSlow[1])
        {
         PrintFormat("CLOSE: maFast[1] < maSlow[1] (%.7f < %.7f)",maFast[1],maSlow[1]);
         CloseAllPositions();
        }
      if(PositionsTotal()==0 && maFast[0]<maSlow[0] && maFast[1]>maSlow[1])
        {
         PrintFormat("BUY: maFast[0] < maSlow[0] (%.7f < %.7f) && maFast[1] > maSlow[1] (%.7f > %.7f)",maFast[0],maSlow[0],maFast[1],maSlow[1]);
         trade.Buy(0.01,_Symbol,0.0,0.0,0.0,NULL);
        }
     }
  }
//+------------------------------------------------------------------+

And here are some screenshots of the tester:

Settings: Settings

1: 1

2: 3

3: 4


And here are my questions:

Picture 1, why is there a autotrade #6 -> #7 on the 4th of january 8am, but journal doesn't show anything for that time?

Picture 1, why is it trading at 8am when the lines are clearly not crossing?

Picture 2: why is it saying that's autotrade #5, when the journal is saying deal 5 takes place the 11th of january?

Picture 2: why is it showing 3 lines going out of autotrade 5, that go close at 3 different times?

Picture 3: what is it doing here? it opens and closes multiple times evend though my conditions are so simple, only do trade on crossing ma.


I know I must be doing something wrong, I'm not blaming mt5.. I just need some help understanding.

Thanks

The "New Bar" Event Handler
The "New Bar" Event Handler
  • 2010.10.11
  • Konstantin Gruzdev
  • www.mql5.com
Authors of indicators and experts have always been interested in writing the compact code in terms of execution time. You can approach to this problem from different angles. From this broad topic in this article we will cover the problem, that is seemingly already have been solved: check for a new bar. This is quite a popular way to limit the...
Reason: