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 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) ) );



Where am I going wrong?





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:

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