#Indicator
'**************************************************************
'*   Zero Lagging Exponential Moving Average (ZeroLaggingEMA.txt)
'*     by Jeremy Williams
'*	   Dec. 10, 2007
'*
'*	Adapted from Technical Analysis of Stocks and Commodities
'*     February 2008
'*
'*  Summary: 
'*
'*      This indicator uses differencing to improve the lag
'*  characteristics of the exponential moving average. For 
'*  more information see "Trading Divergences" in the February
'*  2007 issue of Technical Analysis of Stocks and Commodities.
'*
'*  Parameters:
'*
'*  Periods -  Specifies the number of periods for the calculation 
'*
'************************************************************** 

#Param "Periods",20

Dim EMA1		As Single
Dim EMA2		As Single
Dim Difference	As Single
Dim indValue	As Single

' Calculate the Value of the indicator
EMA1 = EMA(Periods)
EMA2 = EMA(EMA1,Periods)
Difference = EMA1 - EMA2
indValue = EMA1 + Difference

' Plot the value calculated by the indicator in the price pane
PlotPrice("Zero Lag EMA", indValue)

' Return the value calculated by the indicator
Return indValue