Excessive RAM use in an EA

To add comments, please log in or register
Slipshod
10
Slipshod  

I'm delving into some MT4 EA development, and have a problem that's got me stumped.  There's a simple call to a couple of builtin technical indicators as follows:-

double tMA = iMA(symbol, timeframe, MAlen, 0, MAtype, PRICE_CLOSE, shift);

double atr = iATR(symbol, timeframe, ATRlen, shift);

Shift is usually 1, and this is called about 14 times each time a new candle is created, each time for a different currency pair.

The problem is that by the time they're called 14 times, the terminal.exe's RAM usage balloons out from 200,000kb to well over 1gb, and slows the whole computer down.  The next candle it adds another gb.

I've narrowed it down to these two lines - when commented out there's no problem (but the EA obviously doesn't work!)

Any suggestions? 

Simon Gniadkowski
17644
Simon Gniadkowski  
slipshod:

I'm delving into some MT4 EA development, and have a problem that's got me stumped.  There's a simple call to a couple of builtin technical indicators as follows:-

double tMA = iMA(symbol, timeframe, MAlen, 0, MAtype, PRICE_CLOSE, shift);

double atr = iATR(symbol, timeframe, ATRlen, shift);

Shift is usually 1, and this is called about 14 times each time a new candle is created, each time for a different currency pair.

It may well be the history being loaded into memory . . .  try reducing   Tools>Options>Charts  Max bars in history to a few thousand and test again . . .   BUT,  make sure you back up your  hst   files before you make the change and restart MT4 after you make the change.
Slipshod
10
Slipshod  

and here I was thinking it was a coding problem!  Yes, I was testing it on an account where most pairs had over 10 years of history loaded for backtesting purposes.  Tried it on a brand new MT4 install and there's no problem at all.

Thanks Raptor :) 

whroeder1
17951
whroeder1  
RaptorUK: try reducing   Tools>Options>Charts  Max bars in history to a few thousand and test again . .

Max bars in history controls the size of the files on disk

Max bars on chart controls the initial bars per chart and thus memory usage.
To add comments, please log in or register