search Nothing found
Main Algotrading documentation Trade operations Positions

Positions.Count

Get the number of open positions on the account

int Positions.Count

Return value:

int value


Example:

/* Loop through all open positions, find the position labeled MyPositon
and record its unique identifier to myPositionId variable */
int myPositionId = 0;
for (var i = Positions.Count - 1; i >= 0; i--) {
Position pos = Positions.Find(Positions[i].PositionId);
if (pos != null) {
if (pos.Label == "MyPositon") {
myPositionId = pos.PositionId;
}
}


Subscribe to our newsletter and stay up to date with all the news!