OPEN-SOURCE SCRIPT

WaveTrend X

474
WaveTrend X (WVTX)

A WaveTrend rebuild from first principles. Where the classic WaveTrend (LazyBear) normalizes its Channel Index by an arbitrary 0.015 constant inherited from CCI and smooths the result with double exponential moving averages, WVTX replaces both with components that adapt to the data:
  • The CI normalization uses rolling standard deviation instead of 0.015.
  • The smoothing uses a 1-D Kalman filter with ATR-adaptive process noise instead of double-EMA.
  • The fixed ±60 / ±53 OB/OS bands become adaptive rolling-percentile bands.
  • Signals are gated by a Hurst regime proxy (mean-reversion vs trending) and a Shannon entropy filter (noise suppression).
  • Liquidity quality scales line opacity so low-volume readings visually fade.
  • All markers fire only on confirmed bars — explicitly no-repaint.

The default channel and signal periods are tuned for slower, more structural use than classic WaveTrend — see the Notes section for how to revert to classic intraday WT speeds.

How it works

The oscillator is built in five layers:
1. Channel Index (std-normalized). The standard WaveTrend CI is price's deviation from a moving average, normalized by a hard-coded constant. WVTX uses:
Pine Script®

The anchor is VWMA (default) or EMA over the channel period. The stdev is computed over the same window. The constant disappears — the oscillator's amplitude now reflects actual recent volatility, not a one-size-fits-all multiplier.

2. Kalman smoothing. A 1-D Kalman filter replaces the double-EMA that produces the WT1 line in classic WaveTrend. The filter balances two tunable noise terms:
  • Process noise Q — how much you trust the CI to change between bars. Higher = faster, less smooth.
  • Measurement noise R — how much measurement error you assume. Higher = smoother, more lag.


With ATR-adaptive Q enabled (default), Q scales with normalized ATR — so the filter responds faster in volatile conditions and smooths harder in calm ones. This addresses classic WaveTrend's weakness of being either too slow during impulsive moves or too noisy during chop, never both right at once.
WT2 is then a longer EMA of WT1 (the signal line, classic WaveTrend convention).

3. Hurst regime proxy. A two-window standard-deviation ratio approximates the Hurst exponent:
Pine Script®

H > 0.5 = trending (volatility grows faster than √n); H < 0.5 = mean-reverting; H ≈ 0.5 = random walk. The configurable dead-band around 0.5 prevents constant regime-flipping near the boundary.
Signals are gated accordingly: in trending regimes, both cross directions are allowed; in mean-reverting regimes, signals only fire from the extremes (WT1 in the bottom or top 30%) where reversion probability is structurally elevated.

4. Shannon entropy noise gate. The recent return distribution is binned into 8 equal-width bins, and Shannon entropy computed:
Pine Script®

Bounded [0, 1]. Low entropy = concentrated return distribution (structured market); high entropy = uniform distribution (random/noise). When entropy exceeds the configured maximum (default 0.72), signals are suppressed — the oscillator stops emitting markers in conditions where the return statistics suggest no exploitable structure.

5. Adaptive OB/OS. Instead of fixed thresholds, OB and OS bands are the configurable percentiles (default 82% and 18%) of WT1's distribution over a rolling window. The bands move as the oscillator's range shifts — useful for instruments whose volatility regime changes substantially over time.

How to read it

Three lines and an area:
WT1 (main oscillator) — colored by its rolling percentile rank. Cool teal at the high extreme, slate near the middle, coral at the low extreme.
WT2 (signal line) — light slate, follows WT1 with EMA lag.
Diff = WT1 − WT2 (area) — teal area above zero, coral below. Visualizes the momentum between WT1 and the signal line.

Adaptive OB and OS bands are colored by direction (coral above, teal below), with tinted fills extending to the ±50 boundaries.

Background regime tint:
  • Teal — trending regime (Hurst above the band)
  • Purple — mean-reverting regime (Hurst below)
  • No tint — neutral / random walk


Entropy trace (amber, optional) — recentered around zero and scaled for visibility in the same pane. Above zero = recent returns more random than baseline; below zero = more structured.

Signal markers:
  • Teal triangle below pane — confirmed bullish cross (WT1 crosses up WT2, entropy structured, regime allows, WT1 in lower half)
  • Coral triangle above pane — confirmed bearish cross (same gates, opposite direction, WT1 in upper half)


Markers fire only on closed bars. There is no intra-bar signal display, by design.

Inputs

Price source — default hlc3.
Channel period — lookback for the VWMA/EMA anchor and stdev normalization. Default 40.
Signal period — EMA period for the WT2 signal line. Default 16.
VWMA anchor — use VWMA instead of EMA as the price anchor. Default on.
Kalman Q / R — process and measurement noise. Defaults 0.02 / 0.8.
ATR-adaptive Q — scale Q with normalized ATR. Default on.
Hurst regime gate / window / band — toggle, window, dead-band around 0.5. Defaults on / 60 / ±0.05.
Entropy noise gate / window / max — toggle, window, entropy ceiling. Defaults on / 40 / 0.72.
Liquidity quality scale / window — fade line opacity by recent volume rank. Defaults on / 50.
OB/OS rank window / overbought / oversold percentile — sets the adaptive bands. Defaults 100 / 82% / 18%.
Regime background / entropy trace — display toggles.

Built-in alerts
  • Bull cross — confirmed bullish crossover, gates passed
  • Bear cross — confirmed bearish crossover, gates passed
  • Bull cross, deep OS — bull cross from below the 20th percentile (high-quality setup)
  • Bear cross, deep OB — bear cross from above the 80th percentile (high-quality setup)
  • Trending regime — Hurst transitions into the trending zone
  • Mean-rev regime — Hurst transitions into the mean-reverting zone

The two "deep" alerts are the most actionable — a confirmed cross from the extremes of the rolling distribution is structurally more interesting than a cross near the middle.

Notes

The classic LazyBear WaveTrend uses channel period 10 and signal period 21 — fast, oscillator-style behavior suited to intraday momentum trading. WVTX's defaults are 40 and 16, four times slower. This is deliberate: with adaptive smoothing (Kalman + ATR), liquidity scaling, and entropy/regime gating layered on top, fast periods produce too many marginal signals for the gates to filter cleanly. Slower periods produce fewer but more structural crosses, which is where the gates earn their keep. If you want classic intraday WaveTrend behavior, set channel period to 10 and signal period to 21 — the math still works, just with more frequent (and noisier) output.
The Kalman smoother is the most consequential of the rebuilds. Classic WaveTrend's double-EMA introduces predictable lag that traders learn to anticipate; the Kalman filter's adaptive smoothing means the lag isn't constant — it tightens in fast moves and relaxes in chop. For mean-reversion traders, this means signal markers are closer to the actual reversal pivot. For trend-followers, it means the oscillator follows directional moves more responsively.
The Hurst regime gate makes the indicator behave differently in different markets. In a trending instrument (most major indices in their secular uptrends), the gate is permissive — crosses fire freely. In a mean-reverting instrument (ranging FX pairs, sideways equities), the gate restricts crosses to the extremes of the rolling distribution, where reversion probability is highest. The dead-band around 0.5 prevents flickering when the regime is ambiguous.
The entropy gate is the most novel filter. It asks a different question from regime detection: not "what kind of market is this" but "is there any structure in the recent return distribution?" When entropy is high (close to 1.0), the distribution looks essentially uniform — no recurring pattern for an oscillator to exploit. The gate stops signals from firing in those conditions, which historically catches a lot of false WaveTrend crosses during news-driven chop.
The adaptive OB/OS bands are tuned for traders who switch between instruments. Fixed ±60/±53 levels work fine on a single instrument with stable volatility; they're systematically wrong on instruments whose volatility regime changes substantially. Percentile bands self-calibrate, so the same indicator settings work across SPY, BTC, and EURUSD without manual retuning.
The non-repaint design is enforced by barstate.isconfirmed — signals fire only when the bar has closed and won't be revised. Intra-bar, you may see WT1 approaching a cross; the marker only appears once the bar closes with the cross confirmed. The conservative choice: signals you can rely on for backtesting and live execution, at the cost of waiting until the bar ends.
This is a signal generator with multiple filtering layers — but a signal is information, not an instruction.

Five years of work on a trading system left me with dozens of indicators that ultimately didn't earn a place in the final build. They're not failures — they're tools that solved problems I no longer needed solved. So instead of shelving them, I'm publishing the majority of them open-source.
If you're a discretionary trader, take what's useful. If you're a systems builder, the source is yours to dissect, modify, and improve. The best return on five years of work is for it to keep working — for someone.
If you use this script — or part of it — in your own work, please credit the original with a link back to my profile.
Note: these indicators have been updated to Pine Script v6 — some manually, some with AI assistance.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。