Get Breakeven price from open orders of the same symbol in the same direction

 

Have this code to get Breakeven from a deal:

double Breakeven+=Volume*OrderLots;

By the way, it doesn't work if there's just an order, so I set BE=OP as default.

So how should I set the code to filter when it's more than one order on the same symbol in the same direction from a single chart?

Tried this, but unsuccesful:

if(PositionSelectByTicket(ticket)==true&&
PositionGetSymbol(POSITION_SYMBOL)==PositionGetString(POSITION_SYMBOL)){
        Breakeven+=Volume*OpenPrice;Print("Breakeven is ",Breakeven);

Thank you in advance.

 
David Diez:

Have this code to get Breakeven from a deal:

By the way, it doesn't work if there's just an order, so I set BE=OP as default.

So how should I set the code to filter when it's more than one order on the same symbol in the same direction from a single chart?

Tried this, but unsuccesful:

Thank you in advance.

Hi all, nobody responded but it's quite simple and gonna let the solution here for everyone who needs:

double Breakeven=0,Volume=0;
Volume+=OrderLots(); // Get volume total by OrderLots() sum.
Breakeven+=(OrderLots()*OrderOpenPrice())/Volume; // Get breakeven for open positions.

Orders must be same symbol and directionto work properly.

Reason: