Difference between iATR and iMAOnArray? SOLVED

 

Hi

I have an EA that uses this:

res = iATR(Symbol(),Period(),theAtrPeriod,shift);

And an ATR indicator that uses this:

AtrBuffer[i]=iMAOnArray(TempBuffer,Bars,AtrPeriod,0,MODE_SMA,i);

I noticed that sometimes the output can be slightly different ie the indicator maybe change form 0.0021 to 0.0022 while the EA maybe still at 0.0021 and sometimes vice versa, can someone explain why this is please as I am new to coding and keen to learn.

Thanks

Antony

 

This difference between them is this: 1.0000000046511560159

Thanks

Antony

 

[0.0021 & 0.0022 symptom]

mathematically,

(N1 + N2 + N3) / N4

is the same as

N1/N4 + N2/N4 + N3/N4

but not using double in a computer program.

Maybe they use slightly different algorithms (mathematically the same) that produce different answers

[diff of 1.000000000nnn]

dunno

Reason: