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.
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 :)
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.Hi,
can we limit how much bars are loaded when we call iHigh or iLow functions in mql4?
Becouse now it happenes that I call this functions for all timeframes and when i do this on 5 pairs the RAm is full and MT4 frezze.
How can I limit iHigh or iLow functions to load only 10 bars, becouse I dont need more that that for some calculations?
Br, Igor
What part of “Max bars on chart controls the initial bars per chart and thus memory usage” was unclear?
Ok let me explain situation
I have both setting set to 2147483647.
Now I have indicator placed on H1, but there is a function that search some patterns on all timeframes. This is why all timeframes are loaded into RAM when calling iHigh function for each timeframe.
But when I am calling iHigh for last 10 candles, for the rest milions candles I am not interested and they are loaded into RAM for nothing...
My question is, can we get values of last 10 candles without loading the whole milion bars history into RAM?
Wiliam I am not ignoring. There is just missunderstanding.
I want to have all available history on chart for level analysis. This is why I have "Max bars on chart" also set to max.
Let say that you have open chart on H1, but your indicator scan for patterns in background on all timeframes from M1 to MN.
In this case MT4 will load history from all timeframes into RAM. For example when you call this code below from H1 chart timeframe, then you will have loaded both timeframe history into RAM. (H1 and M1)
But you are only want to get value from 10 bar on M1 timeframe.
iHigh("USDCHF",PERIOD_M1, 10 )
I just want to point out that a lot of RAM is filled if we want to have "Max bars on chart" settings to full available but only want to access 10th bar on all timeframes.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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?