OrderProfit giving wrong value - page 2

 
WHRoeder:
  1. Not clear? What part of Returns the net profit value (without swaps or commissions) confused you? What broker do you know charges commissions in pips?
  2. Tick Value must be used as a ratio

return(DeltaValuePerLot() * pips2dbl);

where the pips2dbl get value?..

 
  1. Posted my code Why is there NO Complete EA within the Code-Base? - MQL4 forum It has not been adjusted for Build 600+.
  2. Now I use pips_to_change
    #define  CHANGE         double      ///< Difference of two prices.
    #define  POINT          int         ///< `CHANGE / _Point`.
    #define  PIP            double      ///< `POINT / PipsPerPOINT`.
    CHANGE   points_to_change(POINT n){          return n * _Point;                }
    POINT    change_to_points(CHANGE c){         return POINT(c / _Point + 0.5);   }
    CHANGE   pips_to_change(PIP n){     return points_to_change(pips_to_points(n));}
    PIP      change_to_pips(CHANGE c){  return points_to_pips(change_to_points(c));}
    // Digits DE30=1/JPY=3/EURUSD=5 10 pt/PIP.  forum.mql4.com/43064#515262
    // tick 0.5       tick = point = 0.001
    POINT    pips_to_points(PIP n){              if( (_Digits&1) == 1)   n *= 10.0;
                                                 return POINT(n);                  }
    

 

Thank you brother @WHRoeder..

 
mark:

Sorry for the noob question, but all along i thought the orderprofit() function would be smart enough to give true pip value, but it doesnt seem so.

Im testing on 4 digit broker Fxpro, and the profit of 30 pips is returning as 300 via OrderProfit(). How can i fix this ?

thx

I encountered this problem today, and it's really anoying....

From the documentation of OrderSelect(), it says:

To find out from what list the order has been selected, its close time must be analyzed. 
If the order close time equals to 0, the order is open or pending and taken from the terminal open orders list. 

So it's crucial that OrderCloseTime() should be tested --- not OrderClosePrice()!

This issue wasted me several hours... from morning till mid night... Glad I figured it out.