Multiple cBots - Debugging

Created at 11 Jan 2022, 01:12
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NC

ncel01

Joined 19.03.2020

Multiple cBots - Debugging
11 Jan 2022, 01:12


Hello,

 

I found an issue (amount of open+pending orders not behaving as expected), only when running several cBot instances in real time. There is no issue when running/backtesting a single cBot.

However, real time debugging is not really feasible and also is also a hard task.

Is there any better alternative to this, considering that it is not possible to backtest several cBots as a whole strategy?

 

Thank you!

 


@ncel01
Replies

amusleh
11 Jan 2022, 08:32

Hi,

Each instance of a cBot runs separate from others, one can't have any effect on other running cBots.

Most probably something is wrong with your cBot code, and its not related to running multiple instances.

You should use unique labels for each of your running cBot instances, and use it to only manage the positions and orders that were opened by that instance.

Please post your cBot code then we will be able to help you.

Regarding debugging multiple running instances, right now there is no feasible way to do this.


@amusleh

ncel01
23 Jan 2022, 19:13

RE:

amusleh said:

Hi,

Each instance of a cBot runs separate from others, one can't have any effect on other running cBots.

Most probably something is wrong with your cBot code, and its not related to running multiple instances.

You should use unique labels for each of your running cBot instances, and use it to only manage the positions and orders that were opened by that instance.

Please post your cBot code then we will be able to help you.

Regarding debugging multiple running instances, right now there is no feasible way to do this.

Hi amusleh,

In fact, every single order has a unique label based on its position (numbering) and respective cBot instance.

Still, I'll try to have this solved while implementing some other improvements to the cBot,
Should I am still unable to solve this I'll let you know.

cBot code is really extensive ( > 1000 lines) to go through it, I am afraid.
Maybe if I only post the relevant classes this would be enough? Perhaps some issue can be already identified when checking these.

 

Thank you once again!


@ncel01

ncel01
01 Feb 2022, 23:50

RE: RE:

ncel01 said:

amusleh said:

Hi,

Each instance of a cBot runs separate from others, one can't have any effect on other running cBots.

Most probably something is wrong with your cBot code, and its not related to running multiple instances.

You should use unique labels for each of your running cBot instances, and use it to only manage the positions and orders that were opened by that instance.

Please post your cBot code then we will be able to help you.

Regarding debugging multiple running instances, right now there is no feasible way to do this.

Hi amusleh,

In fact, every single order has a unique label based on its position (numbering) and respective cBot instance.

Still, I'll try to have this solved while implementing some other improvements to the cBot,
Should I am still unable to solve this I'll let you know.

cBot code is really extensive ( > 1000 lines) to go through it, I am afraid.
Maybe if I only post the relevant classes this would be enough? Perhaps some issue can be already identified when checking these.

 

Thank you once again!

Hi amusleh,

Apparently this is now solved by following your suggestion to the thread https://ctrader.com/forum/calgo-support/37501?page=1#4

var myPositions = Positions.Where(position => position.Label.Equals("MyLabel", StringComparison.OrdinalIgnoreCase)).ToArray();

var myOrders = PendingOrders.Where(order => order.Label.Equals("MyLabel", StringComparison.OrdinalIgnoreCase)).ToArray();

Looks like .ToArray() reference made the difference here!

Thank you!!


@ncel01