Download MetaTrader 5

How to preserve variables values when turns off an EA

To add comments, please log in or register
gedavid
136
gedavid  

Hello,

I don´t know if this is the right place to question this, so sorry it is not:

I have an EA that assigns a value to a global variable with every tick, whis is at the start initialized to zero. 

I want to know if it is possible to preserve the value assigned trough a switch off/on of the EA, so that when i initialized again the program the zero value were not assigned to the variable but the last known value. I need that it works like an input type variable and maintain its value when I turns off the EA.

Perhaps is a big silly question, but i haven´t found the answer in the documentation.

Thak you very much in advance,

Alain Verleyen
Moderator
29859
Alain Verleyen  
gedavid:

Hello,

I don´t know if this is the right place to question this, so sorry it is not:

I have an EA that assigns a value to a global variable with every tick, whis is at the start initialized to zero. 

I want to know if it is possible to preserve the value assigned trough a switch off/on of the EA, so that when i initialized again the program the zero value were not assigned to the variable but the last known value. I need that it works like an input type variable and maintain its value when I turns off the EA.

Perhaps is a big silly question, but i haven´t found the answer in the documentation.

Thak you very much in advance,

It's the right place and a very common question, don't worry.

You have several choices, the main two are :

Global variables of the Terminal.

Write/Read from a file.

gedavid
136
gedavid  
angevoyageur:

It's the right place and a very common question, don't worry.

You have several choices, the main two are :

Global variables of the Terminal.

Write/Read from a file.

Thank you very much, I have read it and the use of files is what I was looking for. 

To add comments, please log in or register