Zero lag EMA

I’m trying to create a zero lag EMA script but there seems to be an error with my syntax.

The formula (from https://www.technicalindicators.net/indicators-technical-analysis/182-zlema-zero-lag-exponential-moving-average) is:

Lag: [(n day’s period -1) /2 ]

Entry data for EMA: [Close + (Close - Close of the day lag ago)]

ZLEMA = EMA of (Entry data for EMA)

 

My script is (for a 50 period ZLEMA):

 

P1 = 50;

Lag = ((P1 - 1 ) / 2 );

EMA1 = (Close() + (Close() - Close(Lag) ) );

ZLEMA = EMA(EMA1);

 

Where am I going wrong?

 

Thanks

Steve

 

Hi Steve,

I think the issue is how you’re referencing P1 in the second line. For information on how to reference a variable like that please refer to the following article:

https://help.optuma.com/kb/faq.php?id=964

Additionally on the last line, EMA() is not a valid scripting function. You’d need to use MA(STYLE=Exponential)