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); }
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?