Positions.FindAll("Label") - Filter for more then 1 Label
Positions.FindAll("Label") - Filter for more then 1 Label
11 Feb 2019, 17:33
Hey,
I would like to know if it's possible to filter for more then 1 Label in the "Positions.FindAll" command.
The situation is, that I have 2 Labels for each trade direction ("Long" and "Short") and want to set stops to breakeven after gaining X amount of Pips. Therefor I would like to do something like this:
var AllPositions = Positions.FindAll("Long" and "Short", Symbol);
Otherwise I will have to let this part run 2 times with "Long" and "Short" labels separate, which would be inefficient as I just want him to find all open positions of this Symbol regardless of the label.
Please let me know if this is possible under the current API.
Thank you very much
Replies
TakeProfit
11 Feb 2019, 18:12
Hi Panagiotis,
Thank you very much, it works, I went with the following addition to also filter for Symbol.Code.
- var OpenPositions = Positions.Where(x => x.SymbolCode == Symbol.Code && x.Label == "Long" || x.Label == "Short");
foreach (Position position in OpenPositions)
{...}
@TakeProfit
PanagiotisCharalampous
11 Feb 2019, 17:36
Hi TakeProfit,
You can use Linq to achieve this. See below
Best Regards,
Panagiotis
@PanagiotisCharalampous