How to run 2 instances of one robot for the same currency pair independently.

Created at 05 Jan 2019, 12:57
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!
SY

sylwester.guzek

Joined 05.01.2019

How to run 2 instances of one robot for the same currency pair independently.
05 Jan 2019, 12:57


I have tuned my robot and I found that 2 different sets of parameters works well. Now I would like to run robot with 2 instances for the same currency pair but with different input parameters. How to run them independently ?

I am referring to following line which I have in the code:

             var longPosition = Positions.Find(label, Symbol, TradeType.Buy);

'label' is the same for both instances so for example first instance may find open positions of second instance.

 

I tried following but it doesn't work:

I created robot parameter to assign custom name:

         [Parameter("Custom name", DefaultValue = "std")]
        public string CustomName { get; set; }

......

         public string label = "test-01DE" + CustomName;

but I receive error:

"Error CS0236: A field initializer cannot reference the non-static field, method, or property 'cAlgo.Robots.RobotDAX.CustomName.get'"

 

Thanks in advance for any help

SYlwester

 


@sylwester.guzek
Replies

DelFonseca
06 Jan 2019, 02:58

Hey,

You need add your parameter "CustomName" to the trading syntax, not to the string label declaration.
 

Here you only declarate a name to your label:

private const string Label = "test-01DE";

Here you add the parameter "CustomName":

ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, Label + CustomName);

After that just add 2 cbots with diff "CustomName", you can add to the same chart.
I hope i can have helped you and im sory for my English.


@DelFonseca

sylwester.guzek
08 Jan 2019, 12:59

RE:

Thank you, It solved my problem


@sylwester.guzek

... Deleted by UFO ...