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
AlgoCorner
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);
@AlgoCorner

... Deleted by UFO ...