Is it possible to count long and short positions separately in cAlgo?!?

Created at 28 Oct 2014, 19:02
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!
97

9718853

Joined 14.10.2014

Is it possible to count long and short positions separately in cAlgo?!?
28 Oct 2014, 19:02


If I want to count all positions I can use this:

}
            if (Positions.Count < 5)
            {

Is there any way I can count long and short positions separately?

Thank you in advance...

 


@9718853
Replies

Spotware
29 Oct 2014, 09:34

You can use the following code snippet:

var shortPositionsCount = Positions.Count(p => p.TradeType == TradeType.Sell);
var longPositionsCount = Positions.Count(p => p.TradeType == TradeType.Buy);

 


@Spotware

9718853
30 Oct 2014, 00:19

Great, thank you....


@9718853

.ics
13 Mar 2015, 03:01

RE:

Spotware said:

You can use the following code snippet:

var shortPositionsCount = Positions.Count(p => p.TradeType == TradeType.Sell);
var longPositionsCount = Positions.Count(p => p.TradeType == TradeType.Buy);

 

Hi spotware,

Could you please explain what this is below? Is this some kind of filter or query? It seems very interesting...

p => p.TradeType == TradeType.Sell

Thanks in advance.


@.ics

Hyperloop
14 Mar 2015, 02:01

It's a lambda expression. 

http://www.dotnetperls.com/lambda


@Hyperloop

.ics
15 Mar 2015, 05:26

RE:

Hyperloop said:

It's a lambda expression. 

http://www.dotnetperls.com/lambda

Thank you Hyperloop.


@.ics