MT5 Strategy tester giving totally different results. PLEASE HELP!!!

 

Hello, 

I've been testing some EA on MT5 strategy tester. But I'm getting 2 totally different results from running the strategy tester with and without visual mode. I think It should be reasonable to believe in the results of visual mode testing. And since the optimization results are based on non-visual mode testing, it makes the results of optimizations totally worthless.

I'm so shocked and feels like everything I've been doing up until this point was totally fake and waste of time...

Please someone help me!

 
QTZ :

Hello, 

I've been testing some EA on MT5 strategy tester . But I'm getting 2 totally different results from running the strategy tester with and without visual mode. I think It should be reasonable to believe in the results of visual mode testing. And since the optimization results are based on non-visual mode testing, it makes the results of optimizations totally worthless.

I'm so shocked and feels like everything I've been doing up until this point was totally fake and waste of time...

Please someone help me!

So far, We see a lot of emotions, but no technical details.

So: what is the build of the terminal? What are the testing settings? What tick generation mode was used? What are the advisor settings? The advisor himself?

 
Vladimir Karputov:

So far, We see a lot of emotions, but no technical details.

So: what is the build of the terminal? What are the testing settings? What tick generation mode was used? What are the advisor settings? The advisor himself?


Hello, thank for responding. Yea you're right. I'm new to this programming game so I really have no idea.

Here is a simple example ea that gives different results:

#include <Trade\Trade.mqh>
CTrade Trade;
int AsoHandle = 0;
int AtrHandle = 0;

enum ENUM_MODE
  {
   MODE_RSI,   
   MODE_STO   
  };
input uint                 InpPeriod         =  5;        
input uint                 InpPeriodSm       =  2;            
input ENUM_MODE            InpMode           =  MODE_STO;    
input ENUM_MA_METHOD       InpMethod         =  MODE_EMA;
input ENUM_APPLIED_PRICE   InpAppliedPrice   =  PRICE_CLOSE; 

int OnInit()
  {
   AtrHandle = iATR(Symbol(),Period(),14);
   AsoHandle = iCustom(Symbol(),Period(),"ASO",InpPeriod,InpPeriodSm,InpMode,InpMethod,InpAppliedPrice);
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
   IndicatorRelease(AtrHandle);
   IndicatorRelease(AsoHandle);
  }
void OnTick()
  {
   OpenPosition();
  }
void OpenPosition(void)
  {
   double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
   double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);

   MqlRates rt[2];
   CopyRates(_Symbol,_Period,0,2,rt);
   if(rt[1].tick_volume>1)
      return;

   double bull[];
   double bear[];
   CopyBuffer(AsoHandle,0,0,4,bull);
   CopyBuffer(AsoHandle,1,0,4,bear);
   ArraySetAsSeries(bull,true);
   ArraySetAsSeries(bear,true);
   double atr[];
   CopyBuffer(AtrHandle,0,0,1,atr);
   ArraySetAsSeries(atr,true);
   bool pos = false;

   int total = PositionsTotal();
   if(total <= 0)
     pos = true;

   string signal = "";

   if(bear[2] > bull[2] && bear[1] < bull[1])
     signal = "LONG";
   if(bear[2] < bull[2] && bear[1] > bull[1])
     signal = "SHORT";

   if(signal == "LONG" && pos)
     Trade.Buy(0.01,Symbol(),Ask,Ask-atr[0]*1.5,Ask+atr[0]);
   if(signal == "SHORT" && pos)
     Trade.Sell(0.01,Symbol(),Bid,Bid+atr[0]*1.5,Bid-atr[0]);
  }

  


Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
To obtain the current market information there are several functions: SymbolInfoInteger(), SymbolInfoDouble() and SymbolInfoString(). The first parameter is the symbol name, the values of the second function parameter can be one of the identifiers of ENUM_SYMBOL_INFO_INTEGER, ENUM_SYMBOL_INFO_DOUBLE and ENUM_SYMBOL_INFO_STRING. Some symbols...
 
QTZ :


Please insert the code correctly using the button Code(the first time I corrected your message). Second, you MUST:

  • show the EA settings in the strategy tester (screenshot of the 'Inputs' tab)
  • show the settings of the strategy tester (screenshot of the 'Settings' tab)


Your code is using a third party indicator - attach this indicator. Without a third-party indicator, no one can check anything.

 

I have the same problem!

Visual Mode -2000 €

Optimizer +4000 €

its totally different!

 

 

Same problem here.

  1. Using genetic optimization.
  2. Results reported by optimization are different than that of running with the context menu "Run Single Test," which is then different than using the start button.
  3. On multiple runs using the context menu "Run Single Test" or the start button, the results change drastically.

In summary:

  1. The extreme instability of results in different runs of the same setting renders this feature useless.
  2. I see this problem has been mentioned over the years in different threads, with no real and final resolution.

 

Configuration:

  • Tested with V5 build 3337 and other V5 builds since  June 2021
  • Our EA uses custom-designed indicators. Both EA and indicators were checked extensively to ensure error-free running.
  • We have searched and implemented every solution discussed on the internet
    • Checking for updating any missing data prior to running
    • Ensuring the input is correctly entered manually before running the test
    • Running MT5 and tester fresh after optimization
    • Ensuring indicators buffers are copied correctly in onTick
    • Comparing the journal logs in different runs.
    • For most of the tests we used 1 minute OHLC data, but the problem appears when using Every Tick as well
    • With and without forward option.
    • With and without delays.

 

  • The only thing that only reduced the number of variations seen in the results was the Emptying tester cache. Although it didn't resolve it and still a huge difference between optimization reports and the single run results exists.

MT5 team, please consider that this is a huge source of waste of time, energy, and money for many many people.

 

I was having the same issue when optimizing symbol WIN$D in Brazilian market, which has tick size of 5.

But it was intermittent. At the result table, some results when I ran single test, the output was the same, some were different. Sometimes they were all correct.

I did several fixes but none worked, like deleting some cache files, only using local farm, or only local processor, checking my code for uninitialized variables or structures, etc.

Until I saw on test log that some tests had this error of invalid price, due to price no multiple of 5 (tick size):

failed exchange buy 5 WIN$D at 136712, close #2 sell 5 WIN$D.15R 136500 [Invalid price]

The weird part was this didn't happen all the times, considering same symbol, same EA, same parameters. I don't understand why sometimes MT5 sends correct price and other times don't. Testing with market closed, in history, with no prices changing. So seems like a bug to me.

Well, the fix was to adjust the price to me multiple of tick size, to use in all calls, like position open, position modify, etc. A function as simple as this:

double AdjustPriceTick(double price)
{
   double tick_size = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
   return MathRound(price/tick_size)*tick_size;
}
  

I always used this fix so I didn't understand why this issue was happening. I use CTrade class, so all prices in Buy, BuyLimit, BuyStop, Sell, SellLimit, SellStop, PositionModify functions I pass it adjusted.

The problem was on PositionClose function, which doesn't have a price argument, and it was sending orders with incorrect price.

So to fix it, I copied Trade/Trade.mqh to Include folder with a different name and modified PositionClose function to adjust price to close positions.

And DONE, no more errors or different results!!