MetaTrader 4 and MetaTrader 5 Memory and Data Loading Management Comparison - page 4

Young Ho Seo  
Tsvetan Tsvetanov:

Most likely the problem comes from the historical data?  MT4  needs only  M1 bars in order to create all other timeframes. MT5 is using the real tick data to create all time frames.  The processing of tick data takes more time and more resources.


You are correct but still it should not threat user with freeze or near freeze of their window by just calling 500 data points.

I did not call 50000 or 500000 of data.

Young Ho Seo  
Alain Verleyen:

Finally something constructive, thanks. Trying it...

Which build did you use, still 1958 ? (1959 is now available).

How much symbols in your Market Watch ?

You can try with over 30 to 50 symbols. It is the number typically loaded by many traders.

Fernando Carreiro  
Tsvetan Tsvetanov: Most likely the problem comes from the historical data?  MT4  needs only  M1 bars in order to create all other timeframes. MT5 is using the real tick data to create all time frames.  The processing of tick data takes more time and more resources.

Incorrect! MT5 is the one that builds all the time-frames from M1 data, not MT4 which builds up each time-frame separately, each from its own source data feed and this is the reason there is usually mismatch errors in the Strategy Tester on MT4.

Also on MT5 tick data is build up separately from OHLC data. Tick data is not used to build up OHLC data, at least not on the Terminal side.

Alain Verleyen  
Fernando Carreiro:

Incorrect! MT5 is the one that builds all the time-frames from M1 data, not MT4 which builds up each time-frame separately, each from its own source data feed and this is the reason there is usually mismatch errors in the Strategy Tester on MT4.

Also on MT5 tick data is build up separately from OHLC data. Tick data is not used to build up OHLC data, at least not on the Terminal side.

Exact. Happy you wrote it, as I didn't want to start a new polemic with people only interested by subjectivity.

On topic, tests are underway and all assumptions will be clarified.

Alain Verleyen  

EDIT : I realized that the results I posted yesterday concerning CPU/RAM was flawed because the MT4 platform I was running was on a SSD. So I updated the results, running both platforms on the same hard disk.

So, I will create several posts in a raw to present the tests and the results I have done.

My computer config :

Terminal    Windows 10 (build 17134) x64, IE 11, UAC, Intel Core i5-3317U  @ 1.70GHz, Memory: 4302 / 7893 Mb, Disk: 232 / 464 Gb

MT5 Build 1959, which is a beta version was used, and MT4 build 1090 which is last official release. I setup both platforms with exactly the same workspace : 10 symbols in Market Watch, 1 EURUSD/M1 chart open and 65000 chart bars. These were done a Saterday, so the markets were closed. Could be interesting to compare too, when they are open.

MT4 Workspace

MT5 Workspace

No code is running, the platforms are just started.


Both platforms using approximately the same RAM. However I noticed MT4 is continuously running the CPU, while MT5 works by "peaks" : most of the time 0 then every x a CPU peak between 1 and 2%.

So I let both platforms run for a while, and use "Apps history" tab from Task Manager to check CPU usage of both platforms (after a reset). Interestingly MT4 uses more than twice CPU time in this situation (doing nothing).


As you may note, I will also use Sysinternals Process Explorer (which is a great tool) for these comparison tests.

Alain Verleyen  

EDIT : I realized that the results I posted yesterday concerning CPU/RAM was flawed because the MT4 platform I was running was on a SSD. So I updated the results, running both platforms on the same hard disk.

Firstly, I will show the memory usage when the script is started :

We can easily see when the indicator was launched.


Please note that the memory usage shown here is not the same kind of memory shown with the Task Manager.

As a first remark, it's perfectly obvious there is a memory peak with MT5, using more memory.

Alain Verleyen  

EDIT : I realized that the results I posted yesterday concerning CPU/RAM was flawed because the MT4 platform I was running was on a SSD. So I updated the results, running both platforms on the same hard disk.

After 10 iterations, memory usage is

MT5 use less memory !

This is after starting MT4 and MT5, with the indicator already attached to the chart.

I also decided for this first test to check that all 10 symbols have all the data downloaded already before starting the indicator. An other test should be done with no data to see what will happen.


A second remark about MT5 when the test is initiated by starting the platform :

2018.12.08 20:19:35.533    293936    Counter: 0, Symbol: CADCHF, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.555    293936    Counter: 0, Symbol: EURGBP, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.561    293936    Counter: 0, Symbol: EURJPY, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.561    293936    Counter: 0, Symbol: EURUSD, M1: 500, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.575    293936    Counter: 0, Symbol: GBPJPY, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.585    293936    Counter: 0, Symbol: GBPUSD, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.593    293936    Counter: 0, Symbol: NZDCAD, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.610    293936    Counter: 0, Symbol: USDCAD, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.622    293936    Counter: 0, Symbol: USDCHF, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1
2018.12.08 20:19:35.632    293936    Counter: 0, Symbol: USDJPY, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1

The first iteration only grab some data for the current open chart.

It's only at the 4th iterations, that all data are available. It's clearly a weakness of MT5.

2018.12.08 20:20:05.501    293936    Counter: 3, Symbol: CADCHF, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 143
2018.12.08 20:20:05.501    293936    Counter: 3, Symbol: EURGBP, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 308
2018.12.08 20:20:05.501    293936    Counter: 3, Symbol: EURJPY, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 240
2018.12.08 20:20:05.501    293936    Counter: 3, Symbol: EURUSD, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 240
2018.12.08 20:20:05.501    293936    Counter: 3, Symbol: GBPJPY, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 240
2018.12.08 20:20:05.502    293936    Counter: 3, Symbol: GBPUSD, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 240
2018.12.08 20:20:05.502    293936    Counter: 3, Symbol: NZDCAD, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 137
2018.12.08 20:20:05.502    293936    Counter: 3, Symbol: USDCAD, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 240
2018.12.08 20:20:05.502    293936    Counter: 3, Symbol: USDCHF, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 240
2018.12.08 20:20:05.502    293936    Counter: 3, Symbol: USDJPY, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 240

This clearly doesn't happen on MT4 :

2018.12.08 20:20:12.638    293936 EURUSD,M1: Counter: 0, Symbol: CADCHF, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256
2018.12.08 20:20:12.638    293936 EURUSD,M1: Counter: 0, Symbol: EURGBP, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256
2018.12.08 20:20:12.638    293936 EURUSD,M1: Counter: 0, Symbol: EURJPY, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256
2018.12.08 20:20:12.638    293936 EURUSD,M1: Counter: 0, Symbol: EURUSD, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256
2018.12.08 20:20:12.638    293936 EURUSD,M1: Counter: 0, Symbol: GBPJPY, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 379, MN1: 88
2018.12.08 20:20:12.638    293936 EURUSD,M1: Counter: 0, Symbol: GBPUSD, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256
2018.12.08 20:20:12.654    293936 EURUSD,M1: Counter: 0, Symbol: NZDCAD, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 454, MN1: 107
2018.12.08 20:20:12.654    293936 EURUSD,M1: Counter: 0, Symbol: USDCAD, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256
2018.12.08 20:20:12.654    293936 EURUSD,M1: Counter: 0, Symbol: USDCHF, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256
2018.12.08 20:20:12.654    293936 EURUSD,M1: Counter: 0, Symbol: USDJPY, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256

However, we have to take all into account, if we check the time needed from the start of the platforms to the first data result, according to the logs, we have:

MT5 : 11.151 seconds

2018.12.08 20:21:12.259    Terminal    Alpari MT5 x64 build 1959 started (Alpari International Limited)
2018.12.08 20:21:23.410    293936    Counter: 0, Symbol: CADCHF, M1: -1, M5: -1, M15: -1, M30: -1, H1: -1, H4: -1, D1: -1, W1: -1, MN1: -1

MT4 : 12.346 seconds

2018.12.08 20:21:15.896    Alpari Limited MT4 build 1090 started (Alpari Limited)
2018.12.08 20:21:28.242    293936 EURUSD,M1: Counter: 0, Symbol: CADCHF, M1: 500, M5: 500, M15: 500, M30: 500, H1: 500, H4: 500, D1: 500, W1: 500, MN1: 256

So if we would modify the script to try again when it doesn't grab the data the first time, there will be no real difference between the platforms.

Alain Verleyen  

Something really important to explain more memory usage by MT5, it uses significantly more active threads.



Alain Verleyen  

Last test I made was to check execution speed. I was expecting, MT5 to be faster or equal to MT4 for such task grabbing data. At my big surprise MT4 was around 25% faster than MT5.

 MT4 (Build 1090)
MT5 (Beta Build 1959)
After a fresh start of the platform
Iteration 100 : took 599 µs, all iterations 262457 µs
Iteration 100 : took 1077 µs, all iterations 267031 µs
Subsequent calls
Iteration 100 : took 582 µs, all iterations 64122 µs
Iteration 100 : took 690 µs, all iterations 81501 µs
 Iteration 100 : took 717 µs, all iterations 68353 µs
Iteration 100 : took 1087 µs, all iterations 84886 µs
 Iteration 100 : took 610 µs, all iterations 62642 µs
Iteration 100 : took 709 µs, all iterations 80307 µs

The test was repeated several times in similar conditions for both platforms, it always give similar results.

Files:
293936.mq5  8 kb