2

My Question is How can I calculate Pip Size in MT4 (without checking symbol name)?


My first Answer is based on checking symbol name:

Use the Digits variable for 5 or 4 digits symbols and set PipSize = 0.0001. if Symbols are JPY fractions, use another values and so on other symbols in Shares and Indices or Spot Metals (like Silver)

double pipSize = 0.0001;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(StringFind("-,XAUUSD,Gold,GOLD,Gold.m,GOLD.m,-",","+Symbol()+",")>0){
    pipSize = 0.1; // updated
   }else if(StringFind("-,XAGUSD,Silver,SILVER,Silver.m,SILVER.m,-",","+Symbol()+",")>0){
    pipSize = 1/500;
   }
//---
   return(INIT_SUCCEEDED);
  }
MohaMad
  • 2,575
  • 2
  • 14
  • 26

2 Answers2

1

GOLD 1 pip is 0.10 not 0.01 (according to COMEX)

double PIP = Point()*(Digits%2==1 ? 10 : 1); // for forex only
Daniel Kniaz
  • 4,603
  • 2
  • 14
  • 20
  • thank you @Daniel , I've updated my code. but I'm looking for Answer to mentioned Question "How can I calculate Pip Size in MT4 (without checking symbol name)". – MohaMad Sep 20 '17 at 10:03
  • 1
    no way, only tick size. if forex - as i showed (edited my reply), but for different instruments it is sometimes really unclear what the pip is and how much it costs. – Daniel Kniaz Sep 20 '17 at 10:29
1

The problem is that the pip size definition is subjective (or at best intersubjective). There is no way to automate this in MetaTrader unless you find a broker with tick size symbol parameter equal to your definition of the pip size for all trading instruments.

Enivid
  • 210
  • 2
  • 9