How to find or select positions by label prefix ?

Created at 06 Sep 2022, 08:00
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!
MongolTrader's avatar

MongolTrader

Joined 12.02.2015

How to find or select positions by label prefix ?
06 Sep 2022, 08:00


I want to use Position.Find or Positions,FindAll function. Then i want to find label by prefix. For example i named my positions EURUSD_Buy EURUSD_Sell but i need to find all positions started with "EURUSD" prefix. 


@MongolTrader
Replies

PanagiotisCharalampous
06 Sep 2022, 08:23

Hi MongolTrader,

Use the below instead

 Positions.Where(p => p.SymbolName == EURUSD_Buy)

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

MongolTrader
06 Sep 2022, 08:55

RE:

PanagiotisCharalampous said:

Hi MongolTrader,

Use the below instead

 Positions.Where(p => p.SymbolName == EURUSD_Buy)

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

I mean find by EURUSD prefix not full name search. It means select all positions started with "eurusd" preifx


@MongolTrader

PanagiotisCharalampous
06 Sep 2022, 09:57

Hi MongolTrader,

Then use Contains function instead

Positions.Where(p => p.SymbolName.Contains("EURUSD_Buy"))

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous