net pip total print out is not accurate

 
I'm trying to print out my net pip total and display it as a comment on my EA. However what i'm seeing is that the new pip total is not accurate. I'm taking the difference from the open price and the bid or ask price, depending if its a sell or bid order. It maybe that the comment is always lagging by maybe one tick. I can tell cause even if i have one order on it seems like its always be off by one pip.

Is there something i'm missing in this pretty straightforward function. To make what it displays in the comment more accurate.


Here is the sample code below:

start()
{

Comment("Pip total:",PipTotal();");
}



int PipTotal()
{
int total =0;
cnt=OrdersTotal();

if(cnt==0)
{
return(total);
}
else
{
for(;cnt>=0;cnt--)
{
RefreshRates();
OrderSelect(cnt,SELECT_BY_POS);
if(OrderMagicNumber()==Magic)
{
if(OrderType() ==OP_BUY)
{
total+=(NormalizeDouble(Bid,4) - NormalizeDouble(OrderOpenPrice(),4))*MathPow(10,Digits);


}
if(OrderType() == OP_SELL)
{
total += (NormalizeDouble(OrderOpenPrice (),4) - NormalizeDouble(Ask,4)) *MathPow(10,Digits);

}
}
}
}
return(total);
}

Do you always need to NormalizeDouble the price?
 
 
 
start()
{   
    Comment("Pip total:",PipTotal();");
}
 
int PipTotal()
{
    int total =0;
    cnt=OrdersTotal();   
    if(cnt==0){
        return(total);
    }
    for(;cnt>=0;cnt--){
        RefreshRates();
        //OrderSelect(cnt,SELECT_BY_POS);
        OrderSelect(cnt,SELECT_BY_POS, MODE_TRADES);
        if(OrderMagicNumber()==Magic){
            if(OrderType() ==OP_BUY){
                //total+=(NormalizeDouble(Bid,4) - NormalizeDouble(OrderOpenPrice(),4))*MathPow(10,Digits);
                total += (Bid - OrderOpenPrice())/Point;                   
            }
            if(OrderType() == OP_SELL){
                //total += (NormalizeDouble(OrderOpenPrice (),4) - NormalizeDouble(Ask,4)) *MathPow(10,Digits);
                total += (OrderOpenPrice() - Ask)/Point;                   
            }
        }
    }
    return(total);
}