Hi everybody,
in a script of mine I have a variable which passes from the initial value of 0 to 1 when during a trade the current price overcomes a threshold. At the end of the market session I turn off my laptop which I'll turn on the next morning. As the trade is still active, when I turn it on I expect that variable will be still set at 1. How can I implement this easily?
Thank you,
auato
question about variable persistence [SOLVED]
Re: question about variable persistence
You could use Global Variable. The value put in these variables are written in a PC register. If you don't reinitialized them, the value will be maintained.
You could also use a text file to store your data. Store them and read them back. Again, the values will be maintained.
Martin
You could also use a text file to store your data. Store them and read them back. Again, the values will be maintained.
Martin
Re: question about variable persistence
Hi Martin, thank you.
Using GVs, if I don't want to lose the value, I have to keep the laptop turned on, havent' I ?
Using GVs, if I don't want to lose the value, I have to keep the laptop turned on, havent' I ?
- Smoky
- Posts: 522
- Joined: 03 Dec 2010
- Location: Thailand
- Has thanked: 99 times
- Been thanked: 125 times
Re: question about variable persistence
Auato, the best way is to store your data in the registry, You can use it as database with direct acces to named values !
take a look https://fx1.net/permvar.php
take a look https://fx1.net/permvar.php
Re: question about variable persistence
How can I implement this easily?
Something like Smoky's suggestion is the best option if you need to store a lot of data but if you really only need a switch (0 or 1 - On/Off etc.) then the easiest solution might be to plot/delete an arrow when needed and regard its absence or presence on the chart as being equal to '0' or '1' respectively.
Re: question about variable persistence [SOLVED]
Before the Smoky's suggestion I implemented the IOData.dll solution which stores the value in a txt file. It seems to work fine but the Smoky's solution looks smarter.