Strategy tester not working when I turn off visual mode testing

 

When I test my strategy using the visual mode the trades are executed at the precise and price and time but when i turn the visual mode off. No trades are executed. I have found the problem is in the multi-timeframe indicator am using. When visual mode is turned of it doesn't seem to calculate data and I don't know why is that. Any help will be highly appreciated


here is the code snippet for my indicator test strategy

//+------------------------------------------------------------------+
#include <Trade\Trade.mqh>
#include <lib_cisnewbar.mqh>


CTrade trade;
CisNewBar newbar;


input ENUM_TIMEFRAMES inpTimeFrame = PERIOD_CURRENT;
input int kPeriod = 5;
input int dPeriod = 3;
input int slwPeriod = 3;

int stc_handle;
double main[];
double signal[];

double prev_main = 0;
double prev_stoch = 0;

int tradeType = 1;
int OnInit()
  {
//--t
      newbar.SetPeriod(PERIOD_M30);
      stc_handle = iCustom(NULL,PERIOD_CURRENT,"mtf stochastic",inpTimeFrame,kPeriod,dPeriod,slwPeriod);
      
      ArraySetAsSeries(main, true);
      ArraySetAsSeries(signal,true);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
      
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

      if (newbar.isNewBar() > 0)
      {
         CopyBuffer(stc_handle,0,0,5,main);
         CopyBuffer(stc_handle,1,0,5,signal);
         
         Print("This is previous main : ", prev_main);
         Print("This is main : ",main[1]);
         Print("This is Previous stochastic : ",prev_stoch);
         Print("This is Previous : ",signal[1]);
         
         if (crossover())
         {
            trade.Buy(0.2);
         }
         if (crossunder())
         {
            //trade.Sell(0.2);
         }
         
         prev_main = main[1];
         prev_stoch = signal[1];
      }
   
  }
//+------------------------------------------------------------------+



bool crossover()
{
   if ((prev_main == 0) || (prev_stoch == 0))
   {
      prev_main = main[1];
      prev_stoch = signal[1];
      return (false);
   }else if ((prev_main < prev_stoch) && (main[1] > signal[1]))// cross up
   {
      return (true);
      
   }
   else
      return (false);

}

bool crossunder()
{
   if ((prev_main == 0) || (prev_stoch == 0))
   {
      prev_main = main[1];
      prev_stoch = signal[1];
      return (false);
      
   }else if ((prev_main >= prev_stoch) && (main[1] < signal[1]))// cross down
   {
      return (true);
   }
   else
      return (false);

}
Files:
 

Try writing the following directive 'tester_everytick_calculate' in the EA

 
Vladimir Karputov #:

Try writing the following directive 'tester_everytick_calculate' in the EA

I have tried adding that property but it still not working

 
musingila # :

I have tried adding that property but it still not working

Did you spell it right?

#property tester_everytick_calculate

(this should be written in the EA, not in the indicator)
 
Vladimir Karputov #:

Did you spell it right?


(this should be written in the EA, not in the indicator)

Yes i have but i still get the same result

 
I've zeroed down the problem to when am using a lower or upper timeframe as the base for my custom indicator. when the data is not available in any of those timeframe i.e barscalculated < bars . it returns (0) which usually means calculate the data on the next tick until data is available. during the visual mode the number of bars calculated usually increase until it calculates the data, but in none visual mode the number of bars calculated stays the same. meaning it doesn't calculate data for new bars.
 
musingila # :
I've zeroed down the problem to when am using a lower or upper timeframe as the base for my custom indicator. when the data is not available in any of those timeframe i.e barscalculated < bars . it returns (0) which usually means calculate the data on the next tick until data is available. during the visual mode the number of bars calculated usually increase until it calculates the data, but in none visual mode the number of bars calculated stays the same. meaning it doesn't calculate data for new bars.

In this case, you need to use the correct indicator. Tip number 1: Throw away the multi-timeframe - first learn how to work with a single timeframe.

 
the multi-timeframe forms the base of my strategy and with a single timeframe indicator i've never gotten such an error
 
musingila # :
the multi-timeframe forms the base of my strategy and with a single timeframe indicator i've never gotten such an error

You need to test two theories: 1. a misspelled MTF indicator. 2. The EA does not process data correctly when there is an error in the indicator.

Reason: