Help Coding a basic indicator

 

Hi,

I come fron another platform and language, so I am new in MQL4.

This is a really simple version of the RAVI indicator. It is giving me some error when I try to load it in the chart.

I would appreciate if someone could fix it for me, so I could learn the right procedure.

The indi is only a Line with this formula: MathAbs(100*(iMA(NULL,0,SMAFast,0,0,0,Count)-iMA(NULL,0,SMASlow,0,0,0,Count))/iMA(NULL,0,SMASlow,0,0,0,Count)).


Tanks a lot in advance

Files:
indi_ravi.mq4  2 kb
 

You have a divide by zero error . . . when would this equal zero ?

iMA(NULL,0,SMASlow,0,0,0,Count)
 

Hi,

It should never be zero. There it is the problem. I have tried many ways to avoid this error, but it keeps there.

The indicator should calculate the difference between 2 moving averages in a percentage way.

The formula is: Absolute value( 100*(FastMA-LowMA)/LowMA).

Do you know how to fix the buffer in order to plot this formula?

Thanks

 
RaptorUK:
You have a divide by zero error . . . when would this equal zero ?
iMA(NULL,0,SMASlow,0,0,0,Count)
when count = Bars-1 .. Bars-SMASlow
Reason: