question about variable persistence  [SOLVED]

Questions about MultiCharts and user contributed studies.
auato
Posts: 79
Joined: 23 Nov 2016
Has thanked: 16 times

question about variable persistence

Postby auato » 21 Jun 2017

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

arjfca
Posts: 1283
Joined: 23 Nov 2010
Has thanked: 724 times
Been thanked: 222 times

Re: question about variable persistence

Postby arjfca » 22 Jun 2017

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

auato
Posts: 79
Joined: 23 Nov 2016
Has thanked: 16 times

Re: question about variable persistence

Postby auato » 22 Jun 2017

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 ?

User avatar
Smoky
Posts: 411
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 67 times
Been thanked: 105 times

Re: question about variable persistence

Postby Smoky » 22 Jun 2017

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

Jad
Posts: 91
Joined: 15 Jun 2014
Has thanked: 13 times
Been thanked: 21 times

Re: question about variable persistence

Postby Jad » 23 Jun 2017

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.

auato
Posts: 79
Joined: 23 Nov 2016
Has thanked: 16 times

Re: question about variable persistence  [SOLVED]

Postby auato » 23 Jun 2017

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.


Return to “MultiCharts”