getting information of several postions

To add comments, please log in or register
Saman719
8
Saman719  

i want to know how to get information of several positions , for example how can i get the profit of 2 open positions

for(int i = 0 ; i<PositionsTotal() ; i++)

       {

         double profit = PositionGetDouble(POSITION_PROFIT);

         Print(PositionGetTicket(i)+"'s profit is "+profit);

}

i'm using this code but it only gives me one of the position's profit.

for example i have ticket 42 with 16 profit and ticket 43 with 8 profit . and it writes 16 profit for both of them

any helps?

Greg Pawlak
145
Greg Pawlak  
Hi, create EA, which will connect your strategy in the market by magic number, then you can send information to e mail about profit. Regards Greg
Edwin Artunduaga
617
Edwin Artunduaga  
for(int i = 0 ; i<PositionsTotal() ; i++)
{
        long ticket = PositionGetTicket(i); // Use this line first to select the position
        double profit = PositionGetDouble(POSITION_PROFIT); // Once you select the position using PositionGetTicket(i) you can use PositionGetDouble()
        Print(ticket,"'s profit is ",profit);
}

You need to select the position before get data, always call PositionGetTicket as first, then you can use PositionGetDouble to get the position info

To add comments, please log in or register