profit calculation for only open buy orders
Ugur Karaes: I am able to get the profit of the first buy trade but when I open another buy it does not sum it. How can I calculate the profit for all open buy orders? Thanks in advance.
You have to select the position within the loop iterations ...
double Profit_Sum = 0; for( int i = PositionsTotal() - 1; i >= 0; i-- ) { if( PositionGetSymbol( i ) == _Symbol ) Profit_Sum += PositionGetDouble( POSITION_PROFIT ); };
I am able to get the profit of the first buy trade but when I open another buy it does not sum it.
How can I calculate the profit for all open buy orders?
Thanks in advance.