Download MetaTrader 5

How to get Profit in Pips?

To add comments, please log in or register
Have you developed a profitable strategy? Share it with millions of traders via Signals!
xxxxxxx yyyyy
57
xxxxxxx yyyyy 2010.04.06 19:33 
Hi All,

how to get profit in pips?

OrderProfit() just for amount deposit, how do we get the profit in Pips?

i tried to use MathRound(OrderProfit()-OrderSwap())/(OrderLots()*MarketInfo(OrderSymbol(),MODE_TICKVALUE)), but not so accurate!!!!!

PLease help, thanks.
csebastian
57
csebastian 2010.04.06 20:16  
dude, the profit in pips is not the difference between the OrderOpenPrice and OrderClosePrice (that's for closed orders; or the current price for opened ones)?
Kenneth Raymond Hubbard
151
Kenneth Raymond Hubbard 2010.04.06 21:03  
int start()
{
  int D_Factor = 1;
  double 
      Profit_Pips;
//----
   if(Digits == 3||Digits == 5)D_Factor = 10;
   for(int i=0;i<OrdersTotal();i++){
       if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
            if(OrderType() == OP_BUY) Profit_Pips = (MarketInfo(OrderSymbol(), MODE_BID) - OrderOpenPrice())/Point/D_Factor;
            if(OrderType() == OP_SELL) Profit_Pips = (OrderOpenPrice() - MarketInfo(OrderSymbol(),MODE_ASK))/Point/D_Factor;
            Print("Order No : " + OrderTicket() + " Profit = " + DoubleToStr(Profit_Pips,1));
       }
         else{
         Print("Access to trades failed with error (",GetLastError(),")");
         break;
         }
      }
//----
   return(0);
}
For an open order, use the difference between current price(Bid/Ask) and the OrderOpenPrice.
dabbler
1103
dabbler 2010.04.06 22:08  
kennyhubbard:
For an open order, use the difference between current price(Bid/Ask) and the OrderOpenPrice.

Kenny, I am assuming this is a Script not an EA. (If it's an EA it will run for ever and fill the logs.)

I notice that you used Point rather than

MarketInfo( OrderSymbol(), MODE_POINT );

which is a bug.


If there are any orders which are not OP_BUY or OP_SELL then you either print an uninitialised variable or the previous value, both of which are unpleasant.

To add comments, please log in or register