Live-Time of an iCustom-indicator?

 

Hi,

the basic question is how long does an indicator live with all its arrays and buffers and is it updated by each tick when called only once?

My objective:

I want to get a long-term average and want to 'offer' this value other EA by using GlobalVariables.

The normal call of this indicator is only 'some' bars back, due to a number of arrays that I have to administarte myself (can't have more than 8 Indicator-buffers) and I don't want them too big.

So if the GlobalVariable does not exist this indicator calls itself by using iCustom(..) in init(). My question when does the indicator 'disappear' from the memory?

This is the code:

...
extern int  drawBars  = 100;
...
int init() {
        if ( drawBars == EMPTY_VALUE ) { // EMPTY_VALUE 
                longEMA =  setInivalue(); 
                drawBars = Bars;
        } else { 
                if ( GlobalVariableCheck( longEMAName ) && drawBars < Bars ) {
                        longEMA = GlobalVariableGet( longEMAName );
                } else {
                        iCustom(NULL, 0, "thisIndi",Extern1,Extern2,Extern3, EMPTY_VALUE,   0,0);
                        longEMA = GlobalVariableGet( longEMAName ); // now calc and set,so get it..
                }
        }
} // end init 
 

gooly:

iCustom(NULL, 0, "thisIndi",Extern1,Extern2,Extern3, EMPTY_VALUE,   0,0);

this indicator calls itself by using iCustom(..) in init(). My question when does the indicator 'disappear' from the memory?

  1. I'm not sure you can call iCustom in init - init can not wait
  2. Why are you calling yourself with the same values you already have and then ignoring the returned value?
  3. If your parameters exactly match your call - there is only one indicator. If they don't match there are two (one hidden).
 
WHRoeder:
  1. I'm not sure you can call iCustom in init - init can not wait
  2. Why are you calling yourself with the same values you already have and then ignoring the returned value?
  3. If your parameters exactly match your call - there is only one indicator. If they don't match there are two (one hidden).

add 1) it works! It continues after iCustom has finished and has set the GlobalValue :)
add 2) not the same value: org call with drawBars=100, iCustom(..) sets this value to Empty_Value to detect this call - not quite clear by me, sorry. Beside that it has to be the same (other) extern values otherwise the long average won't make sense!
add 3) first call.. 2nd call (calc Bars bars: 67'000 bars in m1, 65'000 in m5 only once) .. now it works only with 100 bars

 
just to let everybody know and to close that thread.

the service desk just told me the indicator of iCustom(..) in init() stays alive and cannot be killed :(.

mt4 is not ready to program recursively :(
gooly