# Exponentially Weighted Moving Average Oscillator [BackQuant]

Exponentially Weighted Moving Average (EWMA)
The Exponentially Weighted Moving Average (EWMA) is a quantitative or statistical measure used to model or describe a time series. The EWMA is widely used in finance, the main applications being technical analysis and volatility modeling.

The moving average is designed as such that older observations are given lower weights. The weights fall exponentially as the data point gets older – hence the name exponentially weighted.

Applications of the EWMA

The EWMA is widely used in technical analysis. It may not be used directly, but it is used in conjunction with other indicators to generate trading signals. A well-known example is the Negative Volume Index (NVI), which is used in conjunction with its EWMA.

Why is it different from the In-Built TradingView EWMA
Adaptive Algorithms: If your strategy requires the alpha parameter to change adaptively based on certain conditions (for example, based on market volatility), a for loop can be used to adjust the weights dynamically within the loop as opposed to the fixed decay rate in the standard EWMA.
Customization: A for loop allows for more complex and nuanced calculations that may not be directly supported by built-in functions. For example, you might want to adjust the weights in a non-standard way that the typical EWMA calculation doesn't allow for.

Use of the Oscillator
This mainly comes from 3 main premises, this is something I like to do personally since it is easier to work with them in the context of my system. E.g. Using them to spot clear trends without noise on longer timeframes.

Clarity: Plotting the EWMA as an oscillator provides a clear visual representation of the momentum or trend strength. It allows traders to see overbought or oversold conditions relative to a normalized range.

Comparison: An oscillator can make it easier to compare different securities or timeframes on a similar scale, especially when normalized. This is because the oscillator values are typically bounded within a range (like -1 to 1 or 0 to 100), whereas the actual price series can vary significantly.

Focus on Change: When plotted as an oscillator, the focus is on the rate of change or the relative movement of the EWMA, not on the absolute price levels. This can help traders spot divergences or convergences that may not be as apparent when the EWMA is plotted directly on the price chart. This is also one reason there is a conditional plotting on the chart.

Trend Strength: When normalized, the distance of the oscillator from its midpoint can be interpreted as the strength of the trend, providing a quantitative measure that can be used to make systematic trading decisions.

Here are the backtests on the 1D Timeframe for
BTCUSD
ETHUSD
SOLUSD

When using this script the user is able to define a source and period, which by extension calculates the alpha. An option to colour the bars accord to trend.

This makes it super easy to use in a system.

I recommend using this as above the midline (0) for a positive trend and below the midline for negative trend.
Hence why I put a label on the last bar to ensure it is easier for traders to read.

Lastly, The decreasing colour relative to RoC, this also helps traders to understand the strength of the indicator and gain insight into when to potentially reduce position size.
This indicator is best used in the medium timeframe.

Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.