OPEN-SOURCE SCRIPT

Gravity Trend | ADX Strength Meter & Quality-Scored DMI System

9 197
A fully modular DMI/ADX trend-following strategy built around a live Trend Quality Score rather than a raw crossover signal.

Instead of entering on the initial DI crossover, this script waits for pullback entries within an already-confirmed trend regime (DI direction + ADX strength + optional EMA filter), aiming to capture better average entry prices than chasing the initial signal.

Core features:

Pullback entry engine — enters on EMA reclaim within a confirmed DMI trend regime (toggle back to classic DI crossover anytime)

Trend Quality Score (0–100) — a weighted composite of ADX level, DI spread, ADX slope, and EMA slope, visualized as a glowing trend line whose brightness scales with signal quality

Peak-ADX decay exit — tracks the highest ADX reached since entry and exits once trend conviction decays a set percentage off its peak, independent of price action

True initial stop anchored to strategy.position_avg_price, transitioning into a Chandelier-style ATR trailing stop that only ratchets in your favor

Volatility- and quality-adjusted position sizing — risk per trade scales with ATR and with the current Trend Quality Score

Cooldown filter to avoid re-entering immediately after a stop-out in the same chop zone

Live dashboard table showing ADX, DI spread, trend score, position status, and a self-updating win-rate table bucketed by ADX strength regime at entry — so you can see empirically which trend-strength conditions are actually working on your instrument

Every major mechanic (EMA filter, DI spread minimum, pullback mode, Chandelier trail, ADX decay exit, cooldown, quality-based sizing, and each individual Trend Score component) is independently toggleable — designed for methodical A/B testing rather than a fixed black-box system.

This is a trend-following strategy, not mean-reversion. It is intended for educational and research purposes. Past performance shown in backtests does not guarantee future results — always forward-test and paper-trade before risking real capital, and adjust default parameters (ADX threshold, ATR multiples, EMA lengths) to suit your instrument and timeframe.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.