OrderProfit() ?

 


How does OrderProfit() calculated for open orders ?

what value does it return ?


I have a problem with a code, I think I get it right but it just doesn't work
I am trying to close all profitable orders.

total = OrdersTotal(); //now two orders are open
for(i = 0;i<total;i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderProfit() > 0)
OrderClose(OrderTicket(), OrderLots(), Ask, 3,White);
}

It closes only one order while all orders are profitable. I even delete the line (if(OrderProfit() > 0)) and it keeps closing one order.



 
me == baka :)

I figured out the mistake

after closing the first order, the second order become the first order and there is no order with OrderSelect(1,SELECT_BY_POS,MODE_TRADES);

I fixed the code to start with the last order instead of the first one.
total = OrdersTotal(); //now two orders are open
for(i = total-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderProfit() > 0)
OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
}


still need answer to OrderProfit() way of calculation and return value?
 
anyone ?

How does MT4 calculate OrderProfit() for open orders ?

what value does it return ?
 
lalilo wrote:
anyone ?

How does MT4 calculate OrderProfit() for open orders ?

what value does it return ?
Current profit in the deposit currency
Reason: