OPEN-SOURCE SCRIPT

DEMA Adjusted Average True Range [BackQuant]

Updated
The use of the Double Exponential Moving Average (DEMA) within your Adjusted Average True Range (ATR) calculation serves as a cornerstone for enhancing the indicator's responsiveness to market changes. To delve deeper into why DEMA is employed specifically in the context of your ATR calculation, let's explore the inherent qualities of DEMA and its impact on the ATR's performance.

DEMA and Its Advantages
As previously mentioned, DEMA was designed to offer a more responsive alternative to the traditional Exponential Moving Average (EMA). By giving more weight to recent price data, DEMA reduces the lag typically associated with moving averages. This reduction in lag is especially beneficial for short-term traders looking to capitalize on trend reversals and other market movements as swiftly as possible.

The calculation of DEMA involves the following steps:
Calculate EMA1: This is the Exponential Moving Average of the price.
Calculate EMA2: This is the Exponential Moving Average of EMA1, thus it is a smoothing of a smoothing, leading to a greater lag.
Formulate DEMA: The formula
EMA1 = EMA of price
EMA2 = EMA of EMA1
DEMA = (2 x EMA1) - EMA2
effectively doubles the weighting of the most recent data points by subtracting the lagged, double-smoothed EMA2 from twice the single-smoothed EMA1.
This process enhances the moving average's sensitivity to recent price movements, allowing the DEMA to adhere more closely to the price bars than either EMA1 or EMA2 alone.

Integration with ATR
In the context of your ATR calculation, the integration of DEMA plays a crucial role in defining the indicator's core functionality. Here's a detailed explanation of how DEMA affects the ATR calculation:

Initial Determination of DEMA: By applying the DEMA formula to the chosen source data (which can be adjusted to use Heikin Ashi candle close prices for an even smoother analysis), you set a foundation for a more reactive trend-following mechanism within the ATR framework.
Application to ATR Bands: The calculated DEMA serves as the central line from which the ATR bands are derived. The ATR value, multiplied by a user-defined factor, is added to and subtracted from the DEMA to form the upper and lower bands, respectively. This dynamic adjustment not only reflects the volatility based on the ATR but does so in a way that is closely aligned with the most recent price action, thanks to the utilization of DEMA.
Enhanced Signal Quality: The responsiveness of DEMA ensures that the ATR bands adjust more promptly to changes in market conditions. This quality is vital for traders who rely on the ATR bands to identify potential entry and exit points, trend reversals, or to assess market volatility.

By employing DEMA as the core component in calculating the Adjusted Average True Range, your indicator leverages DEMA's reduced lag and increased weight on recent data to provide a more timely and accurate measure of market volatility. This innovative approach enhances the utility of the ATR by making it not only a tool for assessing volatility but also a more reactive indicator for trend analysis and trading signal generation.

The main concept of combining these is to reduce lag, get a more robust signal and still capture clear trends over medium time horizons.
For me, this is best used in confluence with other indicators, it can be made faster in order to get fasters response time, or slower. This is all depending on the needs of you as a trader.

User Inputs:
The script offers several user-configurable inputs, such as the period lengths for DEMA and ATR calculations, the multiplication factor for the ATR, and options to use Heikin Ashi candles or standard price data. Additionally, it allows for the toggling of visual features, like the plotting of the DEMA ATR and its moving average, and the application of color-coded trends on price bars.

Additional Features:
Moving Average Confluence: Traders can opt to display a moving average of the DEMA ATR, choosing from various types (e.g., SMA, EMA, HMA). This feature provides a layer of confluence, aiding in the identification of trend direction and strength.

Trend Identification:
The script employs logical conditions to ascertain the trend direction based on the movement of the DEMA ATR. It assigns colors to represent bullish or bearish trends, which are reflected in the plotted lines and the coloring of price bars.

Alerts:
Customizable alert conditions for trend reversals enhance the utility of the indicator for active trading, notifying users of significant changes in trend direction.

1D Backtests
We include these backtests as a general proxy for how they work.
Please do your own calibrating to suit it to your own needs and backtest.
Past results don't = future results but they can help you understand how it functions.
BTCUSD
snapshot
ETHUSD
snapshot
SOLUSD
snapshot
Release Notes
Updated Long and Short Signals to

Since the signal is Bool and sends one alert instead of every bar
ATRbackquantbacktestedChart patternscleartrendsDouble Exponential Moving Average (DEMA)Trend Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Check out whop.com/backquant for Access to Invite Only Scripts!
Also on:

Disclaimer