Why JPY pairs returns Digits 5 to me?

 
//+------------------------------------------------------------------+
//|                                                    TradeUtil.mqh |
//|                                             Copyright 2024, Ting |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, Ting"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
class TradeUtil
  {
private:

public:
                     TradeUtil(void);
                    ~TradeUtil();
                    
      
      static double digits;
      static int slippagePoints;
      
      static double pipSize;
      static double tickSize;
      static double lotSize;
      static double lotStep;
      
      static double getSpreadInPip(){
         double a = MathRound((Ask-Bid)/TradeUtil::tickSize);
         double b = (TradeUtil::pipSize/TradeUtil::tickSize);
         Print("Spread in points: ",a);
         Print("PipSize/TickSize: ",b);
         PrintFormat("Pip size - %f; Tick size - %f",TradeUtil::pipSize,TradeUtil::tickSize);
         return a / b;
      }
      static double getLongTP(double movement, double rr){
         return Bid+(TradeUtil::getSpreadInPip()*pipSize)+(movement*rr*pipSize);//or Ask without spread
      }
      static double getLongSL(double movement){
         return Bid+(TradeUtil::getSpreadInPip()*pipSize)-(movement*pipSize);
      }
      static double getShortTP(double movement, double rr){
         return Ask-(TradeUtil::getSpreadInPip()*pipSize)-(movement*rr*pipSize);//or Bid without spread
      }
      static double getShortSL(double movement){
         return Ask-(TradeUtil::getSpreadInPip()*pipSize)+(movement*pipSize);
      }
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
TradeUtil::TradeUtil(void)
  {   
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
TradeUtil::~TradeUtil()
  {
  }
//as per chart(symbol) attached
      double TradeUtil::digits = MathRound(MarketInfo(Symbol(),MODE_DIGITS));
      int TradeUtil::slippagePoints = 10;
      double TradeUtil::pipSize = (Digits == 5 || Digits == 3)? 0.0001:0.01;
      double TradeUtil::tickSize = MarketInfo(Symbol(),MODE_TICKSIZE);
      double TradeUtil::lotSize = MarketInfo(Symbol(),MODE_LOTSIZE);
      double TradeUtil::lotStep = MarketInfo(Symbol(),MODE_LOTSTEP);

I'm totally missed.

Print(TradeUtil::pipSize);// shows 0.0001 since the Digits received is 5 instead of 3, notably it is GBPJPY here

The _Digits variable stores number of digits after a decimal point, which defines the price accuracy of the symbol of the current chart.

You may also use the Digits() function.

 

It freaks my EA, now it keeps saying the spread is high and reject the setup from xxxJPY. USD works fine.

Digits - Checkup - MQL4 Reference
Digits - Checkup - MQL4 Reference
  • docs.mql4.com
Digits - Checkup - MQL4 Reference
 
Oh guess I found it, sorry for silly question, it is the condition check messed it up.

double TradeUtil::pipSize = (Digits == 5)? 0.0001:0.01;