MT4 repeatedly crashing with large chart history

 

Hey guys - before I go into the issue, is this the correct place to ask about MT4 issues? Or if not, could someone please tell me the best place?

 Many thanks 

 
for Mt4-clients yes (terminal.exe, editor, code,..)
 

Ok thanks.

So my style of trading involves being able to pinpoint M1/M5 levels around the current price level. For some pairs, this means looking as far back as 5 years or more. As such, I need to have a large number of bars in my chart history, currently set at 2,000,000.

Now, evidently MT4 doesn't seem to handle this too well. All will be fine for a few hours, then random gaps will start appearing in the data. Either using the "Refresh" option, or deleting a few bars out of the history, re-downloading, recalculating, or re-refreshing does nothing to solve this. Occasionally also, when changing timeframe, MT4 just gets stuck on the "Waiting for update" screen.

The only thing which solves this is restarting the terminal entirely. Usually, after this has happened a few times, MT4 will eventually just start to die completely 30 seconds after loading, with the following error in the event log:

Faulting application name: terminal.exe, version: 4.0.0.765, time stamp: 0x00a66a00
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0xb209a272
Faulting process id: 0x1488
Faulting application start time: 0x01d034f0b312245c
Faulting application path: C:\Program Files (x86)\MetaTrader 4 IC Markets\terminal.exe
Faulting module path: unknown

which is essentially just an unhandleable exception I believe.

At this point, even restarting the terminal won't get rid of these total crashes. I have to close every single chart, shut down the terminal, and then by re-opening it with no charts loaded and opening them all again, I'm good again for a few hours, until the cycle begins again (I look at about 8 charts, so it's not like I've got 30 open).

I suspect this is some sort of memory leak caused by the large amount of data. The MT4 process is using around 1-2GB RAM, but I've got 8GB total, and task manager reports plenty of free physical memory.

I've tried re-installing MT4 entirely several times, beginning with fresh history files, and then redownloading the extra data. Same problem, even with no indicators loaded.

Has anyone else experienced issues like this? Or does anyone have any idea of how to workaround it to stop it happening?

I'm using version 4.00, build 765. 

Any help appreciated.

 
MT4 is not native x64, so it behaves like normal x86 applications.
 

Ah you mean in terms of the maximum amount of memory addressable?

That might explain it, cheers.

If I split my 8 charts across two instances, they'd be able to address 2GB each right?

 

How do you manage to have 2'000'000 bars in chart?

The maximum you can define should be 250'000 in the terminal (Options => Chart => Max Bars in History)

 
You can overtype it, and the setting is respected.
 

Something still doesn't add up here.

Even taking potential memory limitations into account (and this actually suggests MT4 can access 4GB on 64-bit OS http://www.metaquotes.net/en/metatrader4/news/3786), there should be more than enough.

Each bar in the history is comprised of 5 pieces of data: open, high, low, close (double) and volume (long). Both double and long data types are 8 bytes, so this means each bar is 40 bytes. 40 bytes x 2,000,000 bars in chart = 80,000,000 bytes, or approximately 80MB of RAM.

There should be easily more than enough memory to hold even 5,000,000 bars.

It's frustrating, because I'm having to run 2 separate instances now - one of them with fewer chart bars, and one of them with 2mil+ which I consult when I need to check M1 levels from years ago. 

Reason: