TrailingStop-values after reconnect or reboot

To add comments, please log in or register
mtsTrader
49
mtsTrader  

Hello,

I'm currently programming an EA and want to implement a trailing-StopLoss. If an order is open the SL is calculated for the current bar and plotted on the chart. The SL is to be recalculated for the following bars. If the price is exceeded or undershot, the order should be closed. How is this when the Internet connection is broken or a restart of the computer is necessary? How do I do that the SLs are still displayed after a reboot of the computer or a reconnect of internetconnection? The special feature when calculating the SL values ​​is that they are dependent on the account balance. A new calculation of all SL values ​​after a reconnect is therefore difficult I think.

Marco vd Heijden
Moderator
12484
Marco vd Heijden  
Write them to file, or use globals.
William Roeder
20001
William Roeder  
EA's must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV+flush or files) of ticket numbers required.
mtsTrader
49
mtsTrader  
Is there a disadvantage in backtesting speed if I write (and read) in files? To use globals I think will not work because they are resetted after a reboot. Or do you think that I use globals and write this globals also to file?
Marco vd Heijden
Moderator
12484
Marco vd Heijden  

Maybe you might click on the topic links to read about it ?

Global variables are kept in the client terminal for 4 weeks since the last access, then they will be deleted automatically.

And yes if you use filewrite there will be a loss is testing speed, how much will depend on how often you read and save the new values, as well as on the hardware you are using.

mtsTrader
49
mtsTrader  

i had a look at the links but read it not in detail.

I would run the EA on my PC at home and not at the client. I think I have to write in files. 

William Roeder
20001
William Roeder  
mtsTrader: Is there a disadvantage in backtesting speed if I write (and read) in files? To use globals I think will not work because they are resetted after a reboot. Or do you think that I use globals and write this globals also to file?
  1. As I posted above, If you want to recover, you can use GVs if you use flush. No flush, nothing may be saved during crashes/power failures.
  2. Of course writing files will slow down the backtest, but that is for recovery, no need during backtests.
To add comments, please log in or register