Find last opened position

Created at 30 Aug 2018, 22:26
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!
AN

anton.kovalchuk

Joined 01.03.2016

Find last opened position
30 Aug 2018, 22:26


Hi all,

Does it exist Method for find last opened position?

cBot opens several positions with the same label, how I can find last of them? or probably exist a way for modification label for the positions?

 

 

Thank you.


@anton.kovalchuk
Replies

PanagiotisCharalampous
31 Aug 2018, 10:44

Hi Anton,

Here is how

 Positions.Where(x => x.Label == "My Label").OrderByDescending(x => x.EntryTime).First();

Best Regards,

Panagiotis


@PanagiotisCharalampous

anton.kovalchuk
31 Aug 2018, 11:57

Gool..!!!!!

Thank you a lot Panagiotis Charalampous

 


@anton.kovalchuk

jani
25 Nov 2019, 23:21

RE:

Panagiotis Charalampous said:

Hi Anton,

Here is how

 Positions.Where(x => x.Label == "My Label").OrderByDescending(x => x.EntryTime).First();

Best Regards,

Panagiotis

Could you show an example how this is used in a cBot? For example if I want to print out the last opened position time?

I'm trying to limit trade openings OnTick with a timer or a bar counter. Would be nice to have an example code for this I know many other people are looking for the same thing...


@jani

PanagiotisCharalampous
26 Nov 2019, 08:28

Hi Jan, 

Here it is

Print(Positions.Where(x => x.Label == "My Label").OrderByDescending(x => x.EntryTime).First().EntryTime);

Best Regards,

Panagiotis


@PanagiotisCharalampous