Multiple Bots - No more than one open position at a time
Multiple Bots - No more than one open position at a time
10 Mar 2020, 22:52
As per the thread title: Multiple Bots - No more than one open position at a time
Supposing I would like to run bots on several different charts, but I would like to inhibit other bots running on other charts from opening a position if a position has already been opened by another bot running on a different chart. Once the open position is closed, I would like all bots to be free to open a position, but with the same restriction of no more than one open position across all bots that are currently running.
I think I could do this with FreeMargin. Is there a better, more elegant, or more robust method of implementing this type of restriction? How could I deal with the possibility of two or more bots attempting to open positions almost simultaneously, and before the FreeMargin value has been updated? Such a situation might be extremely rare or improbable, but I think it's important to consider all possible events.
Thanks
Replies
Monkey007
13 Mar 2020, 01:56
RE:
PanagiotisCharalampous said:
Hi Monkey007,
To check if there are any positions open, you can check the Positions collection. Regarding simultaneous opening, there is no straight forward general solution to this, it depends on your cBot's architecture. For example you can use a static variable as a flag.
Best Regards,
Panagiotis
Thank you very much. Please could you advise how I should initialise a static variable that is to be shared amongst multiple bots? If I have the initialisation in every bot, will it be ignored for all but the first bot that I run?
@Monkey007
PanagiotisCharalampous
13 Mar 2020, 08:49
Hi Monkey007,
If you will use a boolean flag, you don't really need to initialize it, they are set to false by default. You can set it to to true when an operation begins and false when it finishes.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Mar 2020, 08:39
Hi Monkey007,
To check if there are any positions open, you can check the Positions collection. Regarding simultaneous opening, there is no straight forward general solution to this, it depends on your cBot's architecture. For example you can use a static variable as a flag.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous