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); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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?