Custom MACD Histogram Not Accurate Needing One More Decimal Place: mql4

 

I have created a MACD histogram but it is only showing 4 decimal places such as 0.0013 and I would like 0.00130 so one more place or more. I have tried to use NormalizeDouble but no change... Does anyone know how to add a decimal place to get more accurate readings? Regards.


double currentMACDLine= iMACD(_Symbol, _Period, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);

  double currentMACDSignal = iMACD(_Symbol, _Period, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0);

   double prevMACDLine =iMACD(_Symbol, _Period, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);

   double prevMACDSignal = iMACD(_Symbol, _Period, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1); 

   double currentMACDHistogram= NormalizeDouble((currentMACDLine - currentMACDSignal),6); 

   double prevMACDHistogram = NormalizeDouble((prevMACDLine-prevMACDSignal),6);

Documentation on MQL5: Conversion Functions / NormalizeDouble
Documentation on MQL5: Conversion Functions / NormalizeDouble
  • www.mql5.com
NormalizeDouble - Conversion Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Normalise has nothing to do with the situation. If you have a 5 digit broker, then data will have the 5 digits. The problem in many custom indicators' code, including yours, is that they do not set the number of digits to be displayed in the OnInit event handler.

IndicatorSetInteger( INDICATOR_DIGITS, _Digits );

Forum on trading, automated trading systems and testing trading strategies

How to trim to i.e. 2 decimal places in the Data window?

Fernando Carreiro, 2022.02.10 19:03

Please read the documentation. That is not the way to use the "IndicatorSetInteger" function. That function is used to set properties of an indicator, not to adjust the digits of a variable.

ID

Description

Property type

INDICATOR_DIGITS

Accuracy of drawing of indicator values

int