MACD signal buffer odd result!

 

hi guys

seems i dont get the correct answer out of copybuffer for some reason can anyone shed a light on this plz


double MACD_Array[];
double MACD_SIGNAL_Array[]; 

ArraySetAsSeries(MACD_Array,true);
ArraySetAsSeries(MACD_SIGNAL_Array,true);

int  MACD_Handle=iMACD(_Symbol,_Period,8,17,9,PRICE_CLOSE);
int  MACD_Signal_Handle=iMACD(_Symbol,_Period,8,17,9,PRICE_CLOSE);
     CopyBuffer(MACD_Handle,0,0,14,MACD_Array);         //MAIN   Value
     CopyBuffer(MACD_Signal_Handle,1,0,14,MACD_SIGNAL_Array); //Signal Value
     Print("Main Value: "+MACD_Array[1]+"\n Signal Value: "+MACD_SIGNAL_Array[1]);      

result be like this:

(EURUSD,H1) Main Value: 0.000114997711549325

(EURUSD,H1) Signal Value: -5.978044035721716e-05


why signal value so weird! and how can i fix this

tnX for help in advance

 

Hi


Try this code one 

   double MACD_Array[];

   double MACD_SIGNAL_Array[];

   ArraySetAsSeries(MACD_Array,true);
   ArraySetAsSeries(MACD_SIGNAL_Array,true);

   int  MACD_Handle=iMACD(_Symbol,0,12,26,9,PRICE_CLOSE);
   int  MACD_Signal_Handle=iMACD(_Symbol,0,12,26,9,PRICE_CLOSE);
   CopyBuffer(MACD_Handle,0,0,14,MACD_Array);         //MAIN   Value
   CopyBuffer(MACD_Signal_Handle,1,0,14,MACD_SIGNAL_Array); //Signal Value
   Print("Main Value: "+MACD_Array[0]+"\n Signal Value: "+MACD_SIGNAL_Array[0]);


Hope it help you! It worked for me with diferents parameters for MACD_HANDLE and MACD_Signal_Handle, and also 

I changed this line :  Print("Main Value: "+MACD_Array[0]+"\n Signal Value: "+MACD_SIGNAL_Array[0]);

Best regards

 
Amirfakhredin Ghanbari: why signal value so weird! and how can i fix this
Floating-point has infinite number of decimals, it's your not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia, the free encyclopedia

See also The == operand. - MQL4 programming forum

Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.

If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
          question about decima of marketinfo() - MQL4 programming forum 2016.05.18

 
Amirfakhredin Ghanbari:


Example: 

iMACD value on chart

How to start with MQL5
How to start with MQL5
  • 2020.04.09
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
Reason: