BUG WITH CONVERTING ORDERPROFIT() INTO PIPS - page 2

 
ulukai:
this function is static in the backtests, is that correct ?   

My guess is that this is the cause of your problem... But not sure. I would check the basic equation via a script on a demo and if it works - then there must be a tester specific problem.

 

If I understand what you want, this should return Pip-Value:

int PipValue() { 
   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=NormalizeDouble(OrderProfit()/((OrderClosePrice()-OrderOpenPrice())/Point),2);
       if(OrderType()==OP_SELL) value=NormalizeDouble(OrderProfit()/((OrderOpenPrice()-OrderClosePrice())/Point),2);
     }
  }  
   return(value); 
}
 

difference betwenn Bid and OrderOpenPrice() is 0.00128.

Remember the OrderOpenPrice was the Ask price for a buy

Second you must use MODE_TICKVALUE if the symbol does not end in your account currency. Therefor the above will not work. It also will not work as LOTSIZE may be 100K or 10K depending on the account, (IBFX demo std/mini.) It also will not work between 4 and 5 digit brokers.

Third MODE_TICKVALUE may depend on the current price if the symbol end is not your account currency.

Finally the value may be constant during a tester session. I don't know since I've only played with EURUSD and my account is USD so my TICKVALUE is a constant $1usd or $.10 on a 5 digit broker. You will have to convert the orderProfit into points into pips.

 

ulukai wrote >>

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

...
this function is static in the backtests, is that correct ?    

I have been investigating a related issue which brought me back to this thread. Anyway, during my testing I have verified that your formula for calculating pips from profit works just fine for ALL pairs on my tester (connected to Alpari UK demo). There were no discrepancies. FYI.


Also, from the article Testing Features and Limits in MetaTrader 4:

The deposit currency can be changed, but conversion prices are set, and the current available ones are used

So MarketInfo(OrderSymbol(),MODE_TICKVALUE) is indeed static in the Tester (we already knew that... but this is an official answer).

Reason: