Big issue with strategy tester missing trades, inconsistent data?

 

I am testing my EA using the strategy tester and I have been getting a wierd issue. This is for dec 12 3550 build. metatrader demo account

I noticed that when I run the EA withought visual mode on, it missed trades. So when visual mode is on, it takes all of the trades.


I narrowed this issue down to one of my indicators, using print funciton when I run the tester(every tick and 1 min ohlc), the indicator is getting a completely different value. The other two indicators I used for testing has the right value regardless of visual or non visual mode, one of which uses icustom as well.

But when I run the EA with visual mode on, the indicator has the right values and takes the trades. I am using Icustom to get that indicator

//this is in the onInint()
HandleC2 = iCustom(_Symbol,PERIOD_CURRENT,c2Location);//c2Location is the ind name elsewhere in the code
//handleC2 is a global variable set outside everything
//--

//this is in another method
string CurrentSymbol = Symbol();

double oneArray[]; //[prior,current confirmed,not confirmed]

 bool fillSuper= CopyBuffer(HandleC2,0,0, 3 ,oneArray);

   if(fillSuper == false)

      return "Buffer Not Full";

   double currentOneBar =NormalizeDouble(oneArray[1],10)
//--

and the curreOneBar, has the indicators value. When comparing the visual and non visual, for AUDCAD, it is completely different.

I have tried reinstalling and reinstalling mt5 with all data wiped, still had the same issue.

Then I tried it with another indicator(iCustom), and the same issue, the visual was correct, and the non visual was not, it said the indicators value was something that I couldnt even find moving the mouse around the chart.

For extra context, the indicator values are called (//this is in another method part of the code above), is called once per day only.


Essentially the tester has the correct trades only when visual mode is turned on. Does anyone have any idea about this issue?

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 
dsadsa322:

I am testing my EA using the strategy tester and I have been getting a wierd issue. This is for dec 12 3550 build. metatrader demo account

I noticed that when I run the EA withought visual mode on, it missed trades. So when visual mode is on, it takes all of the trades.


I narrowed this issue down to one of my indicators, using print funciton when I run the tester(every tick and 1 min ohlc), the indicator is getting a completely different value. The other two indicators I used for testing has the right value regardless of visual or non visual mode, one of which uses icustom as well.

But when I run the EA with visual mode on, the indicator has the right values and takes the trades. I am using Icustom to get that indicator

and the curreOneBar, has the indicators value. When comparing the visual and non visual, for AUDCAD, it is completely different.

I have tried reinstalling and reinstalling mt5 with all data wiped, still had the same issue.

Then I tried it with another indicator(iCustom), and the same issue, the visual was correct, and the non visual was not, it said the indicators value was something that I couldnt even find moving the mouse around the chart.

For extra context, the indicator values are called (//this is in another method part of the code above), is called once per day only.


Essentially the tester has the correct trades only when visual mode is turned on. Does anyone have any idea about this issue?

oh never mind, figured it out

 
dsadsa322 #:

oh never mind, figured it out

#property tester_everytick_calculate
?
 
dsadsa322 #: oh never mind, figured it out

Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what?

How To Ask Questions The Smart Way. (2004)
     When You Ask.
          Follow up with a brief note on the solution.

 
William Roeder #:

Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what?

How To Ask Questions The Smart Way. (2004)
     When You Ask.
          Follow up with a brief note on the solution.

so I used 

#property tester_everytick_calculate

as well as adjust my code so that the indicator gets tick info each time rather then in a specific time frame as I originally had.

And managed to make it work, however there are probably more efficient ways of doing it, as it did effect my runtime quite a bit at first.

Reason: