search Nothing found
Main Algotrading documentation Trade operations Positions

Positions[int itemindex]

Accessing a specific position by its index in the array of all positions on the account

Position Positions[int itemIndex]


Input parameters:

Parameter
Type
Description
itemIndex
int
Accessing a specific position by its index in the array of all positions


Return value

It returns an object of Position type with the properties of the selected position

/* 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;
}
}
}