Closing a Position after a cBot Restart
Closing a Position after a cBot Restart
25 May 2020, 21:05
Suppose I entered a position using myResult = ExecuteMarketOrder(...) and before I was able to close the position my cBot was restated for unexpected reason (for example, electricity is down).How can I close the position? the myResult variable is lost.
Thanks
Replies
eynt
26 May 2020, 08:45
RE:
Than you
In order to close the position I need to use ClosePosition which takes a parameter of type Position which does not has a constructor and therefor even if I have all the data from the files I can't create a new position instance in order to close the open position.
@eynt
PanagiotisCharalampous
26 May 2020, 08:51
Hi Yuval,
You don't need to create a position, you can retrieve it from Positions property.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 May 2020, 08:09
Hi Yuval,
You can consider writing information in files instead so that the information is not lost after the cBot is restarted.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous