BUG WITH CONVERTING ORDERPROFIT() INTO PIPS

 

hi,


i have a problem with converting Orderprofit() into Pips. I have tried the following code :


OrderProfit()/OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE) with OrderCommission() is 0


the order for all currency-pairs is a Long-position


Backtesting shows this results :


AUDUSD seems to convert the Profit correct into a Pip-Value, but all other currency-pairs show wrong values . WHY ?


Could you please help me ?


2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 0.01000000 MODE_LOTSTEP
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 100000.00000000lotsize
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 4.00000000 Lots
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 300.74000000 OrderProfit()
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 0.00001000 MODE_TICKSIZE
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 0.00001000 MarketInfo(OrderSymbol(),MODE_POINT)
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 0.68977410 tickvalue
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 108.99945375 OrderProfit()/ OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE) // CORRECT
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 75.18500000 OrderProfit()/ OrderLots()
2010.01.21 01:21:03 2001.01.31 21:45 TS AUDUSD,M30: 0.00109000 BID-OrderOpenPrice() // CORRECT





2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 0.01000000 MODE_LOTSTEP
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 100000.00000000lotsize
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 4.16000000 Lots
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 258.38000000 OrderProfit()
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 0.00001000 MODE_TICKSIZE
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 0.00001000 MarketInfo(OrderSymbol(),MODE_POINT)
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 0.68977410 tickvalue
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 90.04480889 OrderProfit()/ OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE) // WRONG
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 62.11057692 OrderProfit()/ OrderLots()
2010.01.21 01:21:30 2001.01.11 12:04 TS EURUSD,M30: 0.00059000 BID-OrderOpenPrice() //WRONG





2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 0.01000000 MODE_LOTSTEP
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 100000.00000000lotsize
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 3.80000000 Lots
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 245.14000000 OrderProfit()
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 0.00100000 MODE_TICKSIZE
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 0.00100000 MarketInfo(OrderSymbol(),MODE_POINT)
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 0.75869080 tickvalue
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 85.02874432 OrderProfit()/ OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE)
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 64.51052632 OrderProfit()/ OrderLots()
2010.01.21 01:30:22 2001.01.05 20:41 TS EURJPY,M30: 0.07200000 BID-OrderOpenPrice()





2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 0.00000000kommissio
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 0.01000000 MODE_LOTSTEP
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 100000.00000000lotsize
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 3.68000000 Lots
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 307.58000000 OrderProfit()
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 0.00001000 MODE_TICKSIZE
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 0.00001000 MarketInfo(OrderSymbol(),MODE_POINT)
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 0.67781905 tickvalue
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 123.30949065 OrderProfit()/ OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE)
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 83.58152174 OrderProfit()/ OrderLots()
2010.01.21 01:34:25 2001.01.05 08:12 TS EURCHF,M30: 0.00128000 BID-OrderOpenPrice()




2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 0.00000000kommissio
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 0.01000000 MODE_LOTSTEP
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 100000.00000000lotsize
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 3.37000000 Lots
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 245.55000000 OrderProfit()
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 0.00001000 MODE_TICKSIZE
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 0.00001000 MarketInfo(OrderSymbol(),MODE_POINT)
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 0.50954116 tickvalue
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 142.99826484 OrderProfit()/ OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE)
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 72.86350148 OrderProfit()/ OrderLots()
2010.01.21 01:37:48 2007.05.10 03:30 TS AUDNZD,M30: 0.00143000 BID-OrderOpenPrice()

 
I already read this topic, I get there this code
OrderProfit()/OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE)

is correct. AUDUSD and AUDNZD show correct pip-values.


But the other currency-pairs EURUSD, EURJPY,... show wrong values

 
Check Ais's code in that thread for how to do it...
 

Ai`s Code says this code :


Orderprofit / (((MODE_TICKVALUE*MODE_POINT) / MODE_TICKSIZE) * OrderLots)


for EURCHF in my example it is :


307.58000000 / (((0.67781905 *0.00001) / 0.00001) * 3.68) = 123.30949065


This is the same like for this code :


and the difference betwenn Bid and OrderOpenPrice() is 0.00128.

OrderProfit()/OrderLots()/MarketInfo(OrderSymbol(),MODE_TICKVALUE)
 
Don't know. A few months ago I used Ais's code for a similar problem. I don't remember having any problems at the time. Alternatively u can simply see the diff between open price and close price/current price to calculate pips, thus avoiding these calculations. Good luck.
 

but the problem is, I must convert from OrderProfit() into Pips-Profit


Does anybody know another way ?

 
Did u try in a demo and not in the Tester? Tester might be giving u wrong MarketInfo(OrderSymbol(),MODE_TICKVALUE)...
 
ulukai:

but the problem is, I must convert from OrderProfit() into Pips-Profit


Does anybody know another way ?

Try this:

int ProfitPips() { 
   double value=0;
   for (int i=0; i<OrdersTotal(); i++) { 
   if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
   if((OrderSymbol()==Symbol()) && OrderMagicNumber() == MagicNumber) 
     {
       if(OrderType()==OP_BUY) value=(OrderClosePrice()-OrderOpenPrice())/Point;
       if(OrderType()==OP_SELL) value=(OrderOpenPrice()-OrderClosePrice())/Point;
     }
  }  
   return(value); 
}
 

U

And when you have the profit in pips, watch out for differing pip-values between pairs..

So, for example, if you are hedging, you could close n orders for a 'profit' in pips but actually suffer a $ loss :(

FWIW

-BB-

 

ok, first thank you for help


but for my strategy I must convert from the information OrderProfit() into Pip-Value ....


The way from wackena does not fit in this strategy ....


so, I think the problem is the

MarketInfo(OrderSymbol(),MODE_TICKVALUE)





this function is static in the backtests, is that correct ?    
If not ,how can I manually calculate this function ? so it is fluctuating referring to my base deposit currency value , if this helps ...
But mysteriously AUDUSD is calculating Pip-Value correct, all other currency-pairs not ...
Reason: