How do I loop through all the active positions and get their individual information?

To add comments, please log in or register
qwerfd
16
qwerfd  

As the title says. How do I access individual position's information? The thought that comes to mind is looping through all of them and checking them one by one untill I find the one I want. But how do I do that?


If this was some other programming language I could do this but this doesn't work here because PositionGetSymbol(index) doesn't hold any information(?)

for (int i = 0; i < PositionsTotal(); i++) { 
        PositionGetSymbol(i).volume; //Would be i-th position's volume 
        PositionGetSymbol(i).price; //Would be i-th position's price and so on
}
Code2219 or probably 2319
430
Code2219 or probably 2319  
qwerfd:

As the title says. How do I access individual position's information? The thought that comes to mind is looping through all of them and checking them one by one untill I find the one I want. But how do I do that?


If this was some other programming language I could do this but this doesn't work here because PositionGetSymbol(index) doesn't hold any information(?)

Don't make up fantasy functions when they exist already.

PositionGetSymbol() is the start of position analyzing process. it gives you the symbol string, AND SELECTS THE POSITION FOR FURTHER OPERATIONS.
so after you check the symbol, use the other attributes of the position. (retrieve these data using PositionGetDouble and PositionGetInteger ....)


So, the process is :
loop through open positions as you did.
get the symbol (and check if it's the one you want to process)
then get other properties and also filter the positions matching your needs.
qwerfd
16
qwerfd  

Thanks. That's exactly what I was looking for. (My so called fantasy functions were there just as am example to help you understand what I'm looking for.)

To add comments, please log in or register