PROTECTED SOURCE SCRIPT

🧬 DNA Ribbon --Adaptive Trend Wave

71
The DNA Ribbon – Adaptive Trend Wave is an advanced trend-following indicator designed to visualize market momentum, trend direction, and reversals through a dynamic EMA ribbon that adapts in real time to market conditions. Unlike traditional moving average-based indicators that rely on fixed-length inputs, the DNA Ribbon leverages volatility, momentum, and trend strength to intelligently recalibrate its internal logic, allowing it to remain responsive during fast-moving conditions and stable during periods of market noise or consolidation. It was created to provide traders with a smoother, cleaner trend-following experience without the need for manual tuning or constant parameter adjustment.

At its core, the DNA Ribbon uses two exponential moving averages—a fast and a slow EMA—as the structural basis for its ribbon. However, these moving averages are not static. Instead, they are adaptively adjusted based on several dynamic market signals: price velocity, the average directional index (ADX), the relative strength index (RSI), and the average true range (ATR). These inputs feed into a multi-phase adaptive logic system that alters the effective lengths of both EMAs on-the-fly. This allows the ribbon to become more sensitive during breakout conditions or during high-momentum scalping scenarios, while becoming more conservative during choppy or sideways markets.

The first phase of the indicator is market state detection. This is achieved by calculating the ADX over a length of 14 bars (or 7 if scalping mode is enabled), as well as measuring price volatility using ATR. The fast and slow temporary EMAs are used to estimate the slope of the trend using an angular calculation: the arctangent of the difference between the EMAs, converted into degrees. This slope is used in conjunction with ATR-based distance between the EMAs to determine whether the market is trending, ranging, or reversing. If ADX is above 20 and the EMAs are sufficiently separated, the market is considered to be trending. If ADX is low and the EMA distance is small, the market is flagged as ranging. If the slope angle changes dramatically from the previous bar (greater than 20 degrees), the market is considered to be reversing.

In the second phase, adaptive EMA lengths are calculated based on the detected market state. If trending conditions are active, both the fast and slow EMAs are lengthened slightly to reduce noise and avoid premature reactions. If reversal conditions are detected, the EMAs are shortened to become more sensitive and reactive. These adaptive lengths are then used to calculate new EMAs through a custom exponential smoothing function that simulates a true adaptive EMA without using fixed lengths. The formula used is a traditional EMA with a dynamic alpha value: alpha = 2 / (length + 1), where the length is modified based on the market state.

Once the adaptive EMAs are calculated, the indicator proceeds to a third phase: slope recalibration. Here, the difference between the EMAs is again measured, and the slope is adjusted by weighting it with a combination of volatility and momentum factors. The ATR is used to normalize volatility, and RSI deviation from 50 is used as a proxy for directional momentum. This slope weighting ensures that during strong directional moves, the ribbon's slope becomes steeper and more expressive, while during low-volatility drifts it flattens and fades.

A key innovation of this indicator is its AI-based noise filtering and memory retention system. This is implemented through a recursive slope memory variable, which blends the current slope with its historical state based on market velocity and noise. The velocity is defined as the normalized absolute change in price, while the noise level is calculated as the standard deviation of the candle body size relative to ATR. The final slope memory is calculated using a weighted formula that increases responsiveness during fast markets and dampens volatility during chop. This intelligent slope memory acts as a kind of synthetic neural layer, helping the ribbon adapt over time without becoming erratic.

Visually, the indicator plots the fast and slow adaptive EMAs as semi-transparent lines, and fills the space between them with a color-coded ribbon that reflects the slope direction and trend confidence. When slope is positive, the ribbon turns green. When it is negative, it turns red. The strength of the fill is modulated by the current trend state: strong trends are solid, reversals are semi-transparent, and ranges are more faded. This gives the trader a visual cue of both direction and conviction in a single glance.

The indicator includes optional signal labels that mark trend reversals and transitions. These are generated from two primary triggers: when the slope memory crosses above or below zero (indicating a change in trend direction), and when the fast EMA crosses the slow EMA (a traditional moving average crossover). Additionally, a third trigger occurs when ADX crosses above 25, signifying the start of a high-momentum trend environment. Each of these events can trigger alerts, which are preconfigured using `alertcondition()` statements for integration into TradingView's alert system.

An optional scalping mode can be enabled to enhance sensitivity on lower timeframes like the 1-minute or 3-minute charts. This mode shortens the ADX period, increases velocity impact, and decreases the smoothing factor in the slope memory logic. The result is a faster, more agile ribbon ideal for rapid entries and exits in fast markets.

In summary, the DNA Ribbon is a comprehensive, AI-assisted trend visualization system built to adapt in real time to ever-changing market conditions. It integrates classic trend logic with modern enhancements like volatility-weighted slope calibration, dynamic length adjustment, and momentum-aware smoothing. It is suitable for all timeframes and trading styles, including swing trading, intraday scalping, and trend confirmation in confluence systems. It was built with clean visuals, minimal noise, and actionable signals in mind, and is designed to integrate seamlessly into multi-indicator strategies as both a directional bias anchor and a standalone trend engine.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.