Comparing optimization speed between MT4 and MT5 - page 2

 

Thanks, angevoyageur! So I guess it is a dynamic spread recorded live from the broker's feed, and will differ from broker to broker?

 
pipnotic:

Thanks, angevoyageur! So I guess it is a dynamic spread recorded live from the broker's feed, and will differ from broker to broker?

Exactly.
 

Wow, this was definitely a learning curve for me!! After playing around with MT5 for a while, and trying to research the (scarce) information available on MT5 history data, I took the following as important info regarding my goal of comparing the optimization speed between MT4 and MT5:

* MT5 has two different history data file formats: hcc, used for charts, and hcs, used for backtesting; and they are not compatible/interchangeable!!!

* in my understanding, there is a single hcc and hcs file containing all timeframes data of a currency pair for a particular year.

* hcc files seems to contain much more data than hcs files (in my MT5 installation, EURUSD 2013.hcc file size is 5154 kb, while 2013.hcs file size is 675 kb!!

* for both hcc and hcs files, 2012 data is much smaller than 2013 data (?!) 

* both these data files are broker dependent (VantageFX in my case), and there is no way we can edit them!

In light of all this, and seeking to have the most similar MT4 and MT5 environments for my comparison tests, I thought of the following:

* perform MT5 optimizations using the period between Jan and April 2013 (since it looks like there is more data made available by the broker for 2013 than for previous years)

* following RaptorUK's suggestion, export this data from MT5 into CSV (though I would be generating csv data from the hcc file, and not from the hcs file, used by the MT5 optimizations...!)

* import the csv data into MT4

* perform MT4 optimizations using the same period, between Jan and April 2013 

 Hopefully I will get similar number of trades and overall optimization results from both platforms, to validate the comparison.

I would appreciate if anyone has any comments/suggestions regarding my approach, in case I am missing something!! ;-) 

 

Ok, I've exported the EURUSD M1 chart data (hcc file) from MT5 ("saved" M1 chart as csv) and then edited the csv file to contain only the period of interest (January to April 2013).

I then imported the resulting csv file into MT4 creating the EURUSD1.hst file. After that I used the "period converter" script to generate the other time-frame files (M5, M15 all the way to D1).

Before doing any optimization, I wanted to "calibrate" both setups by doing a simple back-test on EURUSD H4 using identical parameters for both the MT4 and MT5 EAs (I used the default "MACD Sample" parameters that come with this EA), in the hope of getting similar results, since I assumed that both EAs are just MQL4 and MQL5 coding of the same strategy.

To my disappointment that was not the case, with MT5 recording less trades and being profitable, while MT4 recorded more trades and was at a loss (could things be more different than that?!?). MT4 ran offline to keep the history data intact, with the spread fixed at 14 points. 

Below are the snapshots of both Results:

MT4 Back-test result 

 MT4 Backtest result

 MT5 Back-test result

 MT5 backtest result

I did notice that my modeling quality in MT4 is only 72% (as opposed to 100% in MT5) and that I have 506 bars and 2576392 ticks modeled (as opposed to 505 bars and 4039733 ticks modeled in MT5), and since the data was exported from MT5 to MT4, I would not have expected that to happen...?!

Are the EAs really the same strategy coded in MQL4 and MQL5?

Could it be that the hcc data (exported from the MT5 chart and used to back-test in MT4) is way different from the hcs data (used in the MT5 backtest)? 

Any suggestions on how to explain this huge discrepancy will be most welcome!! ;-)

 

pipnotic:

...

I did notice that my modeling quality in MT4 is only 72% (as opposed to 100% in MT5) and that I have 506 bars and 2576392 ticks modeled (as opposed to 505 bars and 4039733 ticks modeled in MT5), and since the data was exported from MT5 to MT4, I would not have expected that to happen...?!

Are the EAs really the same strategy coded in MQL4 and MQL5?

Could it be that the hcc data (exported from the MT5 chart and used to back-test in MT4) is way different from the hcs data (used in the MT5 backtest)? 

Any suggestions on how to explain this huge discrepancy will be most welcome!! ;-)

First thing to check is effectively if it's the same strategy. As number of trades are very different.
 

I am attaching both EAs again. They are both called MACD_Sample, both come with the standard Meta Trader installation, and both have the same input parameters.

Unfortunately that is the furthest I can go, as my knowledge of MQL4 & MQL5 is definitely not enough to verify if they implement the same strategy. If someone could have a quick look that would be great!

Otherwise, if anybody has or knows of a robot compiled on both MQL4 and MQL5 that would be great too. Remember, it does not even need to be profitable for the sake of this exercise!! ;-)

Thanks!! 

 

Hello, there! Sorry for the absence of over 6 weeks . If it serves as a good excuse, my second son was born two weeks ago! :-)

Hey, MetaQuotes and RaptorUK, thanks for the good reference articles! The first one was especially helpful, as after reading it I was able to verify that the Moving Average EA present on both MT4 and MT5 was a good EA to use for the optimization speed comparison between both platforms. I decided to use the same currency pair (EURUSD), EA settings and period adopted by Renat (2011.01.01 to 2011.10.01), exporting the M1 history data from MT5 to MT4, and then building the other currency periods with the period converter that comes with MT4. The hardware used were Core i7 computers with 16 MB of RAM

As seen in the following table, performing a back-test with the same settings for DecreaseFactor, MovingPeriod and MovingShift, both EAs executed the same number of trades and arrived at similar balances (despite the different number of ticks) giving me confidence that they could provide grounds for a fair comparison of optimization speed between MT4 and MT5.

platform ticks modeled number of trades  final balance
MT4125200582018849.74
MT5155152152018672.33

 

I performed single and multi-core tests with both MT4 and MT5, also evaluating how hyper-threading affected the optimization performance. Following Metaquotes naming convention, a processing core is referred to as an agent, and each optimization pass is referred to as a task. I need to clarify that, since multi-threading is built into MT5, it is able to send different tasks to available agents; therefore, a single MT5 instance was used during the tests. As MT4 is essentially single-threaded, and can only use one agent, for the multi-core tests I had to launch several instances of MT4 working together in the same optimization, each one using a separate agent.

My first goal was to assess how hyper-threading affected the optimization speed. I performed an optimization with 114 passes using a single agent in both MT4 and MT5, disabling and then enabling hyper-threading through my system BIOS. The results were the following:

Hyper-threadingNumber of Agents MT4 time (CPU usage)MT5 time (CPU usage)
 No116:31 (25%)28:09 (25%)
 Yes116:27 (13%)28:15 (13%)

 

Interesting to verify how performance is virtually the same with or without hyper-threading (HT), even though the CPU usage shown by Task Manager almost halves with HT is enabled. Also very apparent how MT4 is almost twice as fast than MT5 performing the "same" optimization.

I then proceeded to compare multi-agent performance on a single Core i7 system, with the results listed below:

Hyper-threadingNumber of Agents MT4 time (CPU usage)MT5 time (CPU usage)
No44:56 (100%)7:25 (100%)
Yes84:45 (100%)8:02 (100%)

 

As expected, distributing the tasks between agents provided a quick and highly scalable improvement in overall performance, with both MT4 and MT5 calculations being on average 3.5 times faster when the number of agents increased by 4.

MT5, with its built in multi-threading capability, was naturally better equipped to take advantage of the 4 agents, performing 3.8 times faster. The 4 MT4 instances working together, on the other hand, only improved 3.3 times the overall optimization speed.

From these tests I suppose we can conclude that hyper-threading doesn't really add any performance benefit to Metatrader optimization. We can also verify how MT4 is roughly twice as fast than MT5, and that with the proper multi-core implementation it can preserve that speed advantage within any hardware context. 

Tomorrow I hope to be able to post optimization performance results using up to 4 computers (32 agents), this time working on an optimization that requires 1254 passes. See you then! :-)

 

Ok, still on hyper-threading (HT)...

I was curious to see why with HT enabled MT5 performed slightly slower than with HT disabled, so I ran another test, this time using only 7 agents for both MT4 and MT5. This result, together with the previous results for 4 and 8 agents, are listed below:

Hyper-threadingNumber of AgentsMT4 time (CPU usage)MT5 time (CPU usage)
No44:56 (100%)7:25 (100%)
Yes84:45 (100%)8:02 (100%)
Yes74:31 (88%)7:52 (88%)

 

According to Wikipedia, Intel's hyper-threading's main benefit is to be able to schedule two threads or processes simultaneously within the same core when these threads do not share the same execution resources, essentially adding a "logical" core to each physical core. So I would imagine that MT5's result using 7 agents was faster than the one using 8 agents probably because in that way there was always a "free" logical core to handle other OS instructions. If anyone has a better explanation please contribute! :-)

And I would go so far as to say that the MT4 results also support this view, where hyper-threading actually increased the optimization speed of the MT4 setup using 7 agents compared to 4 agents (with HT disabled). Different from MT5, where one program instance managed the entire optimization, the MT4 setup required loading 19 instances of MT4 among the 7 agents, each instance executing 6 tasks (19 x 6=114 total tasks, the same as for MT5). Certainly the "free" logical core added extra performance to the loading/unloading of each MT4 instance. 

OBS: Forgot to mention that times are in minutes:seconds! :-)