Keeping the data of a variable after Stop()
Keeping the data of a variable after Stop()
17 Feb 2022, 14:30
Hello,
Is there a possibility to keep the data of some of variables, to be considered on Start(), after stopping cBot?
Thank you!
Replies
ncel01
18 Feb 2022, 11:57
RE:
firemyst said:
There's at least two easy options:
1) save the values to a data file, and then read the values back in when you restart your bot. You'll probably want to save to an XML or Json file so you have easy parsers available.
2) not the best practice, but you can create static variable collections and reference those. As long as you don't close cTrader, they should be around. However, if you close down cTrader, you'll lose the values in those variables.
Hi firemyst,
Thanks for the tip!
I'll try to implement option 1.
@ncel01
firemyst
18 Feb 2022, 07:08
There's at least two easy options:
1) save the values to a data file, and then read the values back in when you restart your bot. You'll probably want to save to an XML or Json file so you have easy parsers available.
2) not the best practice, but you can create static variable collections and reference those. As long as you don't close cTrader, they should be around. However, if you close down cTrader, you'll lose the values in those variables.
@firemyst