Simple Help - Counting open Buys and Sells

Created at 14 Mar 2014, 16:09
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!
10

1000015

Joined 06.09.2013

Simple Help - Counting open Buys and Sells
14 Mar 2014, 16:09


I am not a programmer but I need help that will seem simple to most.

 

I am looking to count the number of Buys and Sells separately.  I am looking at an "average in" strategy but only want to have 3 positions open in one direction (Long or Short) for a total of 6 open positions.  I will have Buy and Sells running simultaneously. I tried using Position.Count but it counts all of the positions regardless of them being Buy or Sell.  What I want to do is to count the open Buys and then count the open Sells in different variables but can't figure out how to do it.  This probably easy for most in this forum but please give me help if you know the answer.

 

Many thanks :=)


@1000015
Replies

Spotware
14 Mar 2014, 16:49

You can use the following code snippet:

var buyCount = Positions.Where(p => p.TradeType == TradeType.Buy).Count();
var sellCount = Positions.Where(p => p.TradeType == TradeType.Sell).Count();

 


@Spotware

1000015
14 Mar 2014, 17:35

Thank-you. It works great.  I appreciate the quick help.


@1000015