OPEN-SOURCE SCRIPT

Dema AFR | viResearch

Dema AFR | viResearch
Conceptual Foundation and Innovation
The "Dema AFR" indicator combines the Double Exponential Moving Average (DEMA) with an Average True Range (ATR)-based adaptive factor to create a responsive and adaptable trend-following system. The DEMA is known for its ability to smooth price data while reducing lag, making it highly effective for trend detection. By incorporating the ATR as a volatility factor, this indicator adapts dynamically to market conditions, allowing traders to capture trends while accounting for changes in volatility. The result is the Adaptive Factor Range (AFR), which provides clear signals for potential trend shifts and helps manage risk through its adaptive nature. This combination of DEMA smoothing and an ATR-based factor enables traders to follow trends more effectively while maintaining sensitivity to changing market conditions.

Technical Composition and Calculation
The "Dema AFR" script consists of two main components: the Double Exponential Moving Average (DEMA) and the Adaptive Factor Range (AFR). The DEMA is calculated over a user-defined length, smoothing out price fluctuations while reducing lag compared to traditional moving averages. The ATR is used to create a dynamic factor that adjusts the AFR based on market volatility. The factor is calculated by multiplying the ATR by a user-defined factor value, which scales the ATR to define upper and lower bounds for the AFR. The Adaptive Factor Range is derived from the DEMA, with upper and lower bounds set by adding or subtracting the ATR-based factor from the DEMA. When the price moves outside these bounds, the AFR is adjusted, and signals are generated. If the lower bound is exceeded, the AFR adjusts upward, while exceeding the upper bound causes the AFR to adjust downward. This dynamic adjustment helps the indicator stay responsive to market movements.

Features and User Inputs
The "Dema AFR" script provides several customizable inputs, allowing traders to tailor the indicator to their strategies. The DEMA Length controls the smoothing period for the DEMA, while the ATR Period defines the window for calculating the Average True Range. The ATR Factor determines the scale of the adaptive factor, controlling how much the AFR adjusts to volatility. Additionally, customizable bar colors and alert conditions allow traders to visualize the trend direction and receive notifications when key trend shifts occur.

Practical Applications
The "Dema AFR" indicator is designed for traders who want to capture trends while adapting to market volatility. The adaptive nature of the AFR makes it responsive to trend changes, providing early signals of potential trend reversals as the AFR adjusts to market movements. By incorporating ATR into the AFR calculation, the indicator adjusts to changing volatility, helping traders manage risk by staying aligned with market conditions. The AFR also helps confirm whether a price move is supported by momentum, improving the accuracy of trade entries and exits.

Advantages and Strategic Value
The "Dema AFR" script offers a significant advantage by combining the smoothness of the DEMA with the adaptability of the ATR-based factor. This dynamic combination allows the indicator to adjust to market conditions, providing more reliable trend signals in both trending and volatile markets. The adaptive nature of the AFR reduces the risk of false signals and helps traders stay on the right side of the trend while managing risk through volatility-adjusted ranges.

Alerts and Visual Cues
The script includes alert conditions that notify traders of key trend changes. The "Dema AFR Long" alert is triggered when the AFR indicates a potential upward trend, while the "Dema AFR Short" alert signals a potential downward trend. Visual cues such as color changes in the bar chart help traders quickly identify shifts in trend direction, allowing them to make informed decisions in real time.

Summary and Usage Tips
The "Dema AFR | viResearch" indicator provides traders with a powerful tool for trend analysis by combining DEMA smoothing with an ATR-based adaptive factor. This script helps traders stay aligned with trends while accounting for market volatility, improving their ability to detect trend reversals and manage risk. By incorporating this indicator into your trading strategy, you can make more informed decisions, whether in trending or volatile market environments. The "Dema AFR" offers a reliable and flexible solution for traders at all levels.

Note: Backtests are based on past results and are not indicative of future performance.
Average True Range (ATR)Double 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?


Also on:

Disclaimer