After Backtest MT5 takes 15 minutes to generate the Backtest Report

 

Greetings, I have been coding on MQL4 for a year and have recently transitioned to MQL5.

After a Backtest is completed,(non visual mode) MT5 always takes approx, 15 minutes to generate the Backtest Report and Chart with deal maps.

In MT4 Report this is generated < 1 minute.

Please My See my Attached images:

- In the 1st  image, test finished (final balance $$$) at 09:08, and it wasn't until 09:24 I got the Bactest Report.

-I am using Windows 10 64-Bit, Local: 2 Cores, 2x Pentium Dual-Core E5800 @ 3.20GHz, 8191MB (RAM)

Question: Is this Normal For MT5, I thought MT5 was supposed to be quicker, or is it just me?

 
Phil_GMT: After a Backtest is completed,(non visual mode) MT5 always takes approx, 15 minutes to generate the Backtest Report and  Chart with deal maps.

You probably have a huge amount of "Deals" (or maybe many "Pending Order" operations) for the test period.

That has been the only time I have noticed long delays in generating the final test report on MT5.

 
Fernando Carreiro #:

You probably have a huge amount of "Deals" or "Pending Orders" for the test period.

That has been the only time I have noticed long delays in generating the final test report on MT5.

okay thank you,

I will look into that.

 

SOLUTION!!!  On MQL5 iCustom Indicators must be Defined inside int OnInit( )  Function.

I have the solution,

All My MT5 Backtests were extremely slow, even on my other computer that is slightly higher spec of 4 cores. I thought well maybe this is just the way MT5 is, better get used to it.

The Mistake I Made:

On MQL5 iCustom Indicators must be Defined inside int OnInit( )  Function.

In MQL4 I always put iCustom indicators inside OnTick( ), ( I actually only use OnBar() function, which is triggered inside OnTick() ) ,

Now I am wondering should iCustom been inside OnTick() all this time?

So now my MQL5 Backtests are SuperFast; a 10 year USDJPY 1hour Bar Backtest Completed in 6 seconds, thank You!!!

These Resources should help anyone with ultra Slow Backtests.

Comparison of Same EA using iCustom indicator (From OrchardFx):

Using iCustom to write Expert Advisors – Orchard Forex

MQL5 EA: 

mt5_simple_ea_template/Experts/Orchard/iCustom Examples/ParabolicCustom/ParabolicCustom.mq5 at main · OrchardForexTutorials/mt5_simple_ea_template · GitHub

MQL4 EA version of the Above :

mt4_simple_ea_template/Experts/Orchard/iCustom Examples/ParabolicCustom/ParabolicCustom.mq4 at main · OrchardForexTutorials/mt4_simple_ea_template · GitHub
mt5_simple_ea_template/Experts/Orchard/iCustom Examples/ParabolicCustom/ParabolicCustom.mq5 at main · OrchardForexTutorials/mt5_simple_ea_template
mt5_simple_ea_template/Experts/Orchard/iCustom Examples/ParabolicCustom/ParabolicCustom.mq5 at main · OrchardForexTutorials/mt5_simple_ea_template
  • OrchardForexTutorials
  • github.com
Contribute to OrchardForexTutorials/mt5_simple_ea_template development by creating an account on GitHub.
 

Then it seems you never read the MQL5 documentation. It has always been the case that the handle to indicators, such as with iCustom, be obtained in OnInit or class initiators.

It has been discussed many times on the forum and the example code in the documentation even shows the handle being obtained in the OnInit handler.

Documentation on MQL5: Technical Indicators / iCustom
Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
iCustom - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro #:

Then it seems you never read the MQL5 documentation. It has always been the case that the handle to indicators, such as with iCustom, be obtained in OnInit or class initiators.

It has been discussed many times on the forum and the example code in the documentation even shows the handle being obtained in the OnInit handler.

Sigh! You are correct, I did not read the MQL5 Documentation regarding iCustom(), I will have to look at all my MQL4 EAs tomorrow.


@Fernando Carreiro, you are a credit to the MQL4/5 universe.

 
Phil_GMT #: Sigh! You are correct, I did not read the MQL5 Documentation regarding iCustom(), I will have to look at all my MQL4 EAs tomorrow.

@Fernando Carreiro, you are a credit to the MQL4/5 universe.

MQL5 works differently to MQL4.

In MQL4, collecting data from indicators is not via a handle. Instead data is collected directly from the function calls.

So, in MQL4 it is necessary to call iCustom when needed in OnTick, unlike in MQl5.

 
Fernando Carreiro #:

MQL5 works differently to MQL4.

In MQL4, collecting data from indicators is not via a handle. Instead data is collected directly from the function calls.

So, in MQL4 it is necessary to call iCustom when needed in OnTick, unlike in MQl5.

Yes that is what I thought, but was going to double check.

Reason: