Store Array Data or Static Data, In the event Terminal shuts down

 

When using arrays or Static variables which are calculating values needed to be kept for processing in an EA,

Is there away to constantly back up those values calculated somewhere so that if the MT4 Terminal is unexpectedly closed the EA can retrieve those values ?

Any links where I can read more on it would be helpful.

Thanks

 
barnacle7: Is there away to constantly back up those values calculated somewhere so that if the MT4 Terminal is unexpectedly closed the EA can retrieve those values ?
  1. Persistent storage. Write them to a file, read the file OnInit.
  2. Or recalculate the values on startup.
    double arrays[n];
    void Calculating(int i){
      array[0] = Close[i]; 
      :
    }
    OnTick(){
       Calculating(0);
       :
    }
    OnInit(){
       for(int i=Bars-1; i>0; i--) Calculating(i);
       :
 

Another option, depending on your needs, are global variables. However, they do have some shortcomings.

https://docs.mql4.com/globals

Reason: