Using instances (stupid question)

Created at 30 Mar 2016, 08:11
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!
GD

GDPR-24_203122

Joined 02.10.2015 Blocked

Using instances (stupid question)
30 Mar 2016, 08:11


If I use a single bot, which occasionally finds its running positions by label, like this: 

  var B_Posits = Positions.FindAll(Label_B); 

var b_Posits = (B_Posits.Length);

  if (b_Posits == Max_B_positions)

{...}

...and I use multiple instances, don't they all generate trades with same label (Label_B)? If so, the max-positions doesn't work...

 

Should I just duplicate the bot and change the label for each bot? Or is the a way to find to categorize the positions, by instance? 

 

Safe trading, happy results!

 


Replies

... Deleted by UFO ...

Waxy
01 Apr 2016, 06:09

Use a random label generator function and run it before placing the first trade, here's mine:

        protected string GetLabel(string _TType)
        {
            Random rn = new Random(10);
            int x = rn.Next(100, 10000);
            _Label = _TType + x.ToString();

            var _CLD = History.FindLast(_Label);
            var _CLO = Positions.Find(_Label);
            while (_CLD != null || _CLO != null)
            {
                x++;
                _Label = _TType + x.ToString();
                _CLD = History.FindLast(_Label);
                _CLO = Positions.Find(_Label);
                //Theres a duplicated Label, finding another one
            }
            return _Label;
        }

Then do something like

string Label = GetLabel(Symbol.Code);

 


@Waxy

Jiri
01 Apr 2016, 08:57

I usually use this. I suppose you won't let the bot run on same symbol and timeframe multiple times (if sou, you can add parameters into it).

string label = string.Format("cBot name ({0} : {1})", Symbol.Code, MarketSeries.TimeFrame);

 


@Jiri