Why does MACD indicator show 5 decimal places and iMACD() return 4

 

Hi,

Why does the MACD indicator show 5 decimal places and iMACD() return only 4 decimal places?

Try the following EA and add the standard MACD indicator to the chart.

Test conditions:

Server: Alpari UK.

Terminal version 211.

Symbol GBPUSD,M1

My observation is that 5 decimal places of accuracy are significant for the MACD. Surely the inaccuracy of the iMACD() function will adversely affect performance.

Regards,

Jan

int init()
{
 return(0);
}
 
int deinit()
{
 return(0);
}
 
int start()
{
 static int nCount = 0;
 
 nCount++;
 
 if(nCount < 10)
  {
   double dMACD = iMACD(NULL, 
                        0, 
                        12, 
                        26, 
                        9, 
                        PRICE_CLOSE,           
                        MODE_MAIN, 
                        0);
                       
   double dMACDS = iMACD(NULL, 
                         0, 
                         12, 
                         26, 
                         9,  
                         PRICE_CLOSE,          
                         MODE_SIGNAL, 
                         0);  
   
   Print("MACD  ", dMACD);    
   Print("MACDS ", dMACDS);    
  }
 
 return(0);
}
 

void IndicatorDigits( int digits)
Sets precision format (the count of digits after decimal point) to visualize indicator values. The symbol price preicision is used by default, the indicator being attached to this symbol chart.

 
phy:

void IndicatorDigits( int digits)
Sets precision format (the count of digits after decimal point) to visualize indicator values. The symbol price preicision is used by default, the indicator being attached to this symbol chart.

Sorry folks. I gave you a bum steer. It is Print() that rounds doubles to 4 decimal digits. iMACD() actually returns 8 decimal digits (or at least assigning the returned double value to a string and then printing that does).

 

string DoubleToStr(

double value, int digits)

Returns text string with the specified numerical value converted into a specified precision format.

Print("MACD ", DoubleToStr(dMACD,5));

Reason: