question about variable persistence  [SOLVED]

Questions about MultiCharts and user contributed studies.
auato
Posts: 89
Joined: 23 Nov 2016
Has thanked: 18 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: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 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: 89
Joined: 23 Nov 2016
Has thanked: 18 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: 507
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 97 times
Been thanked: 115 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: 92
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: 89
Joined: 23 Nov 2016
Has thanked: 18 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”