Download MetaTrader 5

Can someone please explain this code? And is it neccessary for tickdata backtesting?

To add comments, please log in or register
Do you want to deposit to your account? Do this in any convenient way!
Winsor Hoang
4831
Winsor Hoang 2015.01.29 15:47 

 #include <CustomChartingBacktest.mqh>

and at the very top of the void OnTick() function add the following function call:

if(skipFirstTickOnBacktest()) return;

 

//+------------------------------------------------------------------+
//|                                       CustomChartingBacktest.mqh |
//|                                        Copyright 2012, AZ-INVEST |
//|                                          http://www.az-invest.eu |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, AZ-INVEST"
#property link      "http://www.az-invest.eu"

bool skipFirstTickOnBacktest()
{
   if(!IsTesting())
      return(false);
      
   static datetime lastbar;
   RefreshRates();
   datetime curbar = Time[0];
   if(lastbar!=curbar)
   {
      lastbar=curbar;
      return (true);
   }
   else
   {
      return(false);
   }   
}
To add comments, please log in or register