If buy I calculated the difference between Ask-OpenOrderPrice And if sell between OpenOrserPrice-Bid and then converting in pips . Then at the end summing pips on each order.
for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--)
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol())
if (OrderMagicNumber() == MagicS)
gProfit += OrderProfit(); // add Swap and Commission if you care
gOrdersCount += 1;
gLots += OrderLots();
gWeightedAverage += OrderLots() * OrderOpenPrice();
if (gLots > 0) gWeightedAverage /= gLots;
make sure you init the vars to 0
at the end of this you will all your heart desires -> Profit, Ordercount, Total Lot Size and and average order open price.
you now can use this average order open price similar to how you used diff1 before. Example = ( (gWeightedAverage - Bid) / Point) / Point_Compat. and then normalize it
Your function seems correct to me. Maybe is there some commissions on your account ?
Then do not confuse points with pips.
double DiffPips = (NormalizeDouble(((Ask - diff1)/MarketInfo(Symbol(),MODE_POINT)),(int)MarketInfo(Symbol(),MODE_DIGITS)))/_Point;