Read/Write counter values
Read/Write counter values
15 Jun 2020, 16:02
Hi,
I have written my fist bot but still I am struggle to have everything working as I would like.
The most disadvantage part of cTrader and cAlgo is that you have to run it on a Windows environment. This is very old fashion.
My script is rnow unning on a Windows Server 2019 Virtual Server on Azure Cloud and the problem I am facing now is that the server needs to reboot from time to time because of software updates or other Windows shit.
In my script I am using a buy and sell counter. Based on those counters I make my next buy and sell.
Now when the server reboots and I need to restart my instances I am loosing my counter values.
Is there a way to store my counter values somehow every time they changing and read them back into my instances at startup ?
I have played around with StreamWriter & StreamReader but every time I want to update my counter it add a new line.
Is there no way to work with a settings file or something?
Any idea how to solve this?
Thanks,
Mario
PanagiotisCharalampous
15 Jun 2020, 16:08
Hi Mario,
You can just override the file every time you are writing a new value. You can use File.WriteAllText() to do so.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous