Hi guys,
I would like to to store values of certain variables to be able to reuse them in case of event of a reboot ...
The extern variables can be modified, but aparently they dont stay..
Thanks for your help
Hi,
You can store it to the file https://docs.mql4.com/files
Good luck :)
![File Functions - MQL4 Reference File Functions - MQL4 Reference](https://c.mql5.com/36/14/file-functions-mql4-reference.png)
Hi guys,
I would like to to store values of certain variables to be able to reuse them in case of event of a reboot ...
The extern variables can be modified, but aparently they dont stay..
Thanks for your help
You can also use global variables
![Documentation on MQL5: Global Variables of the Terminal Documentation on MQL5: Global Variables of the Terminal](/i/community/logo_mql5_small.png)
- www.mql5.com
Thanks Yohana,
Can you tell me what kind of file is easier to use for storind few variable numeric values for example. MQL4 file or CSV, or text file. How do you create a file from an EA.
Would you have an example of just create write new file and stroind 2 variables in it, and read it.
THANKS
Thanks Yohana,
Can you tell me what kind of file is easier to use for storind few variable numeric values for example. MQL4 file or CSV, or text file. How do you create a file from an EA.
Would you have an example of just create write new file and stroind 2 variables in it, and read it.
THANKS
We can use any text file types, e.g CSV
Btw, you can find many examples there :)
One of them :
https://docs.mql4.com/files/filewrite
//--- open the file for writing the indicator values (if the file is absent, it will be created automatically) ResetLastError(); int file_handle=FileOpen(InpDirectoryName+"//"+InpFileName,FILE_READ|FILE_WRITE|FILE_CSV); if(file_handle!=INVALID_HANDLE) { PrintFormat("%s file is available for writing",InpFileName); PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH)); //--- first, write the number of signals FileWrite(file_handle,sign_size);
Good luck :)
![FileWrite - File Functions - MQL4 Reference FileWrite - File Functions - MQL4 Reference](https://c.mql5.com/36/14/filewrite-file-functions-mql4-refer.png)
- docs.mql4.com
Hi guys,
I would like to to store values of certain variables to be able to reuse them in case of event of a reboot ...
The extern variables can be modified, but aparently they dont stay..
Thanks for your help
Yes, you can save your variables in a file. But there is another way, you can try to use global variables (do not confuse with external variables): GlobalVariableSet (), GlobalVariableGet (). Global variables are not destroyed on reboot. Global variables exist in the client terminal for 4 weeks after the last access. Best wishes.
Thanks Victor very much,
This much nicer. So it means that the global variables are stored somewere, right ?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
I would like to to store values of certain variables to be able to reuse them in case of event of a reboot ...
The extern variables can be modified, but aparently they dont stay..
Thanks for your help