OPEN-SOURCE SCRIPT

Smart Trail, 9/21 Crossover + VWAP Signals Score

458
Smart Trail + 9/21 Crossover + VWAP with HTF and ADX Filter
A trend-following signal indicator combining a dynamic ATR-based Smart Trail with EMA 9/21 crossover signals, VWAP bias, a higher timeframe alignment filter, and an ADX + DI directional filter — all working together to surface only high-conviction entries.

How It Works
The Smart Trail continuously calculates adaptive support and resistance levels using ATR and a configurable sensitivity multiplier. When the trend flips direction a signal fires — but only after passing the ADX strength filter, DI directional filter, and higher timeframe Smart Trail alignment check.

Scoring System (0–100)
Every Smart Trail signal is scored across three weighted factors:

Smart Trail (default 40 pts) — trend direction confirmation. Full points when trend is aligned.
EMA 9/21 (default 35 pts) — full points when price is above both EMAs and 9 > 21 (bull) or below both and 9 < 21 (bear). Partial (0.5) when mixed. Zero when fully against.
VWAP (default 25 pts) — full points when price is above VWAP for bull signals, below for bear signals.

All weights are fully adjustable. Score normalizes to 0–100 regardless of weight configuration.

EMA 9/21 Crossover Signals
Independent crossover signals plot separately from the Smart Trail signals using a distinct shape (triangle) and color (yellow/orange) so they are easy to differentiate. An optional fill between the two EMAs colors green when 9 > 21 (bullish) and red when 9 < 21 (bearish) — giving instant visual context of EMA stack direction across the whole chart.

Hard Filters (signal blocked entirely if not met)
ADX + DI Filter:

ADX must be above the configured minimum threshold (default 20) — blocks signals during choppy, trendless price action
DI+ must be greater than DI- for bull signals — confirms buyers are in control
DI- must be greater than DI+ for bear signals — confirms sellers are in control
Toggling the ADX filter off disables both the ADX threshold and DI directional checks simultaneously

Higher Timeframe (HTF) Smart Trail Filter:

Runs the same Smart Trail calculation on an automatically determined higher timeframe
Bull signals only fire when the HTF Smart Trail is also bullish
Bear signals only fire when the HTF Smart Trail is also bearish
Auto timeframe mapping: 1m → 5m, 2-3m → 15m, 5m → 30m, 15m → 1h, 30m → 2h, 1h → 4h, 4h+ → Daily
HTF Smart Trail plots as a thicker faded line for visual reference

Session Filter:

Restricts signals to regular trading hours (default 9:30–16:00 ET, fully configurable)


Signal Labels
Each Smart Trail signal prints a scored label directly on the chart:

▲ 85 — bullish flip, score 85
▼ 22 — bearish flip, score 22

Label color is green (≥70), yellow (50–69), or red (<50). An optional rolling score label can be enabled to display the live score at a configurable bar frequency.

Alerts
Two dynamic alert conditions using the alert() function — one for bull, one for bear. Both Smart Trail signals and EMA crossover events trigger the same alert so only one alert needs to be created in TradingView.
Set the alert condition to "Any alert() function call" in the TradingView alert dialog.
Alert message format: Smart Trail: BULL | Score: 82 | ADX: 24 | DI+: 28 | DI-: 18 | HTF: 15m | META | 3m | Price: 626.87

Settings
GroupKey SettingsSmart TrailLength, multiplier, source, sensitivityScore WeightsPer-factor weight (0–100 each)Score FilterMin bull score, max bear scoreSession FilterOn/off toggle, custom sessionADX FilterOn/off toggle, length, minimum thresholdHTF FilterOn/off toggle (auto timeframe)EMA CrossShow/hide signals, show/hide fill, bull/bear fill colorsDisplayRolling score labels, frequency

Recommended Usage
Best used on intraday timeframes (1m–15m). Signals with scores of 70+ where ADX is above 25 and DI direction is clearly aligned represent the highest conviction setups. The EMA fill gives immediate context — trading in the direction of the fill color with a Smart Trail flip confirmation is the core entry pattern.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.