The WilderAverage function calculates the Wilder’s Moving Average, which is a type of exponential moving average developed by J. Welles Wilder. It is primarily used to smooth out price data and is often employed in various technical indicators to reduce volatility and noise. The Wilder Moving Average is different from a simple moving average in that it applies more weight to recent data points, making it more responsive to new information.
WilderAverage[N](price)
Where N represents the number of periods over which the average is calculated, and price indicates the price data (e.g., close, open, high, low) to be averaged.
To calculate the Wilder Moving Average for 26 periods using closing prices and then for 12 periods, you can use the following code:
long = WilderAverage[26](close)
short = WilderAverage[12](close)
WilderMACD = long - short
RETURN WilderMACD
In this example, long and short are variables storing the Wilder Moving Averages for 26 and 12 periods, respectively. The difference between these two averages, termed WilderMACD, is then calculated and returned. This difference can be used as a signal line in trading strategies, similar to how MACD (Moving Average Convergence Divergence) is used.
This function is a fundamental tool in technical analysis for financial markets, helping traders and analysts identify trends and potential reversal points in price movements.