Multiple Robots

Created at 18 Sep 2012, 11:15
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!
SpotTrader's avatar

SpotTrader

Joined 18.09.2012

Multiple Robots
18 Sep 2012, 11:15


Can I run multiple robots at the same time?


@SpotTrader
Replies

admin
19 Sep 2012, 15:31

Hello SpotTrader,

 

Yes you can but make sure that the code of one Robot does not affect the other. For instance one Robot may be closing all positions that are open for the account.

You may use a List to keep track of the positions that each robot is creating and closing:

 

// Declaration
private readonly List _positions = new List();

// OnPositionOpened
protected override void OnPositionOpened(Position openedPosition)
{
        _positions.Add(openedPosition);            
 }
// OnPositionClosed
protected override void OnPositionClosed(Position closedPosition)
{
      if (_positions.Contains(closedPosition))
      {
          _positions.Remove(closedPosition);
       }
}
// access within OnTick/OnBar foreach (Position position in _positions ) { // do something e.g. if(position.NetProfit < ProfitLevel) Trade.Close(position); }

 

 

 


@admin

robl45
21 Oct 2012, 08:37

so there is no magic number or something similar to separate the robots?  If you have 20 bots running, you are relying only on figuring out which one opened a position with the list code that you have listed which i assume will need to be in every bot?


@robl45

admin
22 Oct 2012, 11:14

We are currently working on introducing "labels" in cAlgo that will have the functionality of identifying robots.  It will be available very soon, stay tuned!

 

Best Regards

 


@admin