How to retrieve values for our variables after restarting the VPS?

 

Hi all,

Let's say I have an array which my EA put values for each element after closing each position. But when I restart my VPS, my EA put default values for each element of this array rather than recent values.
Should I store the values in a file in OnDeinit function and recover them in OnInit function after next start? I have no idea how to do this, so it would be greatly appreciated if you give me an example code of how to do this.
Another question is: Is it a safe way? What will happen if my VPS turns of suddenly and my EA had no time to run OnDeinit() before turning off?

 
HosseinKOGO: Should I store the values in a file in OnDeinit function and recover them in OnInit function after next start? I have no idea how to do this
  1. That's the only way for many values. A small number can use Global Variables.

  2. Perhaps you should read the manual. File Functions
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

 
William Roeder #:
  1. That's the only way for many values. A small number can use Global Variables.

  2. Perhaps you should read the manual. File Functions
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

Appreciated!
You've addressed me exactly what I was looking for.
Reason: