First post here, and sorry in advance because i will my problem is trivial...
I have this code and don't understand why I get only "0" values for all the data I try to get back from my opened positions.
If someone can help, thank you in advance.
for(int i=PositionsTotal()-1; i>=0; i--)
int currentPositionType = PositionGetInteger(POSITION_TYPE);
double currentPositionTP = PositionGetDouble(POSITION_TP);
double currentPositionOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN);
double currentPositionCurrentPrice = PositionGetDouble(POSITION_PRICE_CURRENT);
myComment = myComment + "\n Index: " + string(i) + "\n Type: " + string(currentPositionType) + " - TP: " + string(currentPositionTP);
myComment = myComment + "\n OpenPrice: " + currentPositionOpenPrice;
myComment = myComment + "\n CurrentPrice: " + currentPositionCurrentPrice;
You have to select the position before getting any of its properties.
for (int i = PositionsTotal() - 1; i >= 0; i--)
ulong ticket = PositionGetTicket(i);
//... your code here