MT4 Memory Use and Indicators

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
210
edddim 2016.01.25 20:55 #
 
gooly:  2) I wrote an optimizing script that calls an indicator again and again each time with a different setup and immediately I crash the whole pc - out of memory! (after b600+).

So you say if I include without buffer (only 2 for few arrows) some calls of other indicators from one present indicator on the chart, it will accumulate the data from all total calls in memory, unlimited?

I am asking because this week often I spend time and seat in the kitchen on my netbook with 1 gb at all, and just now started to write some indicator tests which I thought will handle them with few mb which I have.

So what is solution without Copy Rates? Possible with calling script from expert, and that script after calculations will release the shanks of memory data not needed any more, or not?


avatar
2017
gooly 2016.01.25 21:49 #
 
It is quite simple: Each call of an indicator with a different or new set-up 'eats' memory which is freed only if the EA or the script or a calling indicator is removed.
avatar
210
edddim 2016.01.25 22:59 #
 
I understand, removing and than put again with new setting will be as first planned codding. So I don't know how to check precisely in the Task Manager resources (or ok linux has conky but I'm in Xp now) I often use similar like this:
   for ( i = limit; i >= 0; i-- )  {
      if(/*...*/true) { last_long = Open[i]; LongEntry[i]=last_long; } // arrow 1 of 2 buffers
      maH = iMA(NULL, 0, 10, 0, 2, PRICE_HIGH, i+1);
      maL = iMA(NULL, 0, 10, 0, 2, PRICE_LOW, i+1);
      SS = High[i]+Low[i] - maH - maL;
      VortSin = Volume[i]* (Close[i]-iMA(NULL,0,2,0,MODE_LWMA,PRICE_MEDIAN,i))
        + Volume[i] * iMACD(NULL,0,1,2,2,4,MODE_SIGNAL,i);
      /* ... plus 10 more indicators without buffers etc. */
    }
And beside the 2 buffers for the arrows and 10-15 variables, after few hours on every tick calling other indicators  will be accumulated in the memory all like in buffer, or I understand wrong?
avatar
2017
gooly 2016.01.26 11:15 #
 

The 'shift' and the 'mode' or 'line index' of an indicator (MACD or iCustom(), ...) is not part of the the set-up. In your case:

iMACD(NULL,0,1,2,2,4,MODE_SIGNAL,i)

the set-up is defined by:

NULL,0,1,2,2,4,

and

MODE_SIGNAL,i

can be varied without any problem.

All of your calls will not cause the discussed problem!

But if you vary e.g. fast and slow period:

...
for (int fast_p=3, fast_p<10, fast_p++) {
   for (int slow_p=12, slow_p<20, slow_p++) {
      iMACD(NULL,0,1,2,2,4,MODE_SIGNAL,i);
      ...
   }
}

you will end up with 7*8 = 56 different MACDs running independently on your pc.

Well this is valid for at least indicators called by iCustom(). Maybe it is different with the built in indicator functions - I can't remember - but I doubt that.

I have sent in an article for review about how one can solve this problem but I haven't get any since Nov. 22, 2015.


avatar
210
edddim 2016.01.26 22:23 #
 
Honestly, now  I see what you are talking about, maybe before 8+ years I was doing something similar but it was in script and also I remember the only difference was (because in indicator it can't work) was Var_sleep_ms of value 0 to 2 (auto if longer than second lasts the calculations), at least to free some cpu if longer calculating was, and I was putting all data in arrays so exactly I remember the MB used maximum, =60, that was when I've tested 360-370 symbols and a lot of indicators data returns stored in arrays, but never had crush of the terminal or fatal freezing with the loops, memory stayed at 60 MB max (beside the terminal itself), and everything was in loop over and over, and never used Print, only Comment for debug what is going on (just was interested for the speed progress and if it stuck somewhere to have the last info). I was clearing any array after not needed any more with data, as internal clear memory chunks, especially strings, and whenever could I was storing the results in 'int'. I don't know what have been changed since than, similar test I did (but with more -file- writes than arrays) before few weeks like post here, but didn't notice 'the memory jumps', maybe, because my window with memory wasn't open. I n what environment were you while you were performing those tests Linux-wine or Windows? Maybe tomorrow I'll try to reproduce what you talk, to see the results.
avatar
2017
gooly 2016.01.26 23:05 #
 

You can use TerminalInfoInteger(x) with x:

TERMINAL_MEMORY_PHYSICAL

Physical memory in the system, Mb

int

TERMINAL_MEMORY_TOTAL

Memory available to the process of the terminal , Mb

int

TERMINAL_MEMORY_AVAILABLE

Free memory of the terminal process, Mb

int

TERMINAL_MEMORY_USED

Memory used by the terminal , Mb

int

avatar
1110
Ovo 2016.01.27 10:53 #
 
gooly:

You can use TerminalInfoInteger(x) with x:

TERMINAL_MEMORY_PHYSICAL

Physical memory in the system,Mb

int

TERMINAL_MEMORY_TOTAL

Memory available to the process ofthe terminal , Mb

int

TERMINAL_MEMORY_AVAILABLE

Free memory of the terminal process,Mb

int

TERMINAL_MEMORY_USED

Memory used by the terminal ,Mb

int

Never tried but now. What surprised me, TERMINAL_MEMORY_USED showed more than twice the value of the task manager.
avatar
736
honest_knave 2016.01.27 11:02 #
 
Ovo:
Never tried but now. What surprised me, TERMINAL_MEMORY_USED showed more than twice the value of the task manager.
When I created a memory usage logger a while ago, I found the figures sketchy too.
avatar
2017
gooly 2016.01.27 11:26 #
 
honest_knave:
When I created a memory usage logger a while ago, I found the figures sketchy too.

I have no deep Windows inside view but may be the calculations are different? Memory that is a) requested but not used yet, b) swapped onto the hd, c) ...?

Back to topics list   | 1 2  

To add comments, please log in or register