iMA calc vs chart problem

 

Hi,


I am using the following command:


MA_prev = iMA(Symbol(), 1440, 14, 0, MA_method, MA_price, 1);


Problem is that the result calculated in MA_prev is different from the result on the relevant H4 chart (all parameters the same).

Help.

 

Can see your ire... but how do you know for sure that calculations of MA applied to chart and iMA() builtin are one and the same?

maybe rhetorical question, but is only idea :)

 
fbj:

Can see your ire... but how do you know for sure that calculations of MA applied to chart and iMA() builtin are one and the same?

maybe rhetorical question, but is only idea :)

Aren"t they?

If so, then the whole MT4 should be thrown away.

 

Show us a picture of your dilemma.

Mine seems to work just fine.

 
zevbn wrote >>

Hi,

I am using the following command:

MA_prev = iMA(Symbol(), 1440, 14, 0, MA_method, MA_price, 1);

Problem is that the result calculated in MA_prev is different from the result on the relevant H4 chart (all parameters the same).

Help.

iMA(Symbol(), 1440, 14, 0, MA_method, MA_price, 1);

you set 1440 for TimeFrame = Day

H4 is 240, so must be iMA(Symbol(), 240, 14, 0, MA_method, MA_price, 1);

Give a try again?!

 
Yes, what he said...
 
EADeveloper:

iMA(Symbol(), 1440, 14, 0, MA_method, MA_price, 1);

you set 1440 for TimeFrame = Day

H4 is 240, so must be iMA(Symbol(), 240, 14, 0, MA_method, MA_price, 1);

Give a try again?!

That was stupid!

I have looked at the damned thing for hours, checking myself again and again.

I must consider retiring....

 
zevbn wrote >>

That was stupid!

I have looked at the damned thing for hours, checking myself again and again.

I must consider retiring....

Better still - why not use the defined constant names? eg, PERIOD_H4

That's what defines/mnemonics are for, they liberate the coder and make maintenance a doddle and as you have just found out: to save hours looking at code which appears ok but has a number which means nothing.

Also, just think what would happen if all the code out there that uses hard coded constants inline will suffer like should MetaQuotes decide that those numbers being used are to change to be some other value???

 
fbj:

Better still - why not use the defined constant names? eg, PERIOD_H4

That's what defines/mnemonics are for, they liberate the coder and make maintenance a doddle and as you have just found out: to save hours looking at code which appears ok but has a number which means nothing.

Also, just think what would happen if all the code out there that uses hard coded constants inline will suffer like should MetaQuotes decide that those numbers being used are to change to be some other value???

Thanks you all!

Reason: