Positions.FindAll("Label") - Filter for more then 1 Label

11 Feb 2019, 17:33Positions.FindAll("Label") - Filter for more then 1 Label#1
TakeProfitposts: 5since: 15 Aug 2017


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

11 Feb 2019, 17:36#2
Panagiotis Charalampousposts: 3188since: 13 Jan 2017

Hi TakeProfit,

You can use Linq to achieve this. See below

var AllPositions = Positions.Where(x => x.Label == "Long" || x.Label == "Short");

Best Regards,


Head of Community Management at cTrader
11 Feb 2019, 18:12#3
TakeProfitposts: 5since: 15 Aug 2017

Hi Panagiotis,

Thank you very much, it works, I went with the following addition to also filter for Symbol.Code.

  1. var OpenPositions = Positions.Where(x => x.SymbolCode == Symbol.Code && x.Label == "Long" || x.Label == "Short");
    foreach (Position position in OpenPositions)