INVITE-ONLY SCRIPT

WaveTrend Oscillator

51
The WaveTrend Oscillator indicator extends the standard WaveTrend algorithm with three capabilities not present in typical implementations: simultaneous display of four timeframes (1-minute, 5-minute, 15-minute, 1-hour) with automatic hiding of lower timeframes to prevent dampened extreme values; a multi-timeframe alignment signal that fires only when three specific timeframes simultaneously occupy extreme zones; and a crossover filtering system that distinguishes first crossovers after entering an extreme zone from subsequent crossovers while still in the zone.

The base WaveTrend calculation (EMA of HLC3 → absolute deviation smoothing → normalized CI → EMA to WT1 → SMA to WT2) is a known public-domain algorithm. The originality of this indicator is in the three systems built on top of it.


WHAT MAKES THIS ORIGINAL

1. Timeframe Hierarchy Auto-Hide
When displaying WaveTrend from a lower timeframe on a higher timeframe chart, the oscillator values become dampened — a 1-minute WaveTrend viewed on a 15-minute chart will never reach true extreme levels because each 15-minute bar averages multiple 1-minute values. Most multi-timeframe oscillator indicators simply show all timeframes regardless, producing misleading readings. This indicator computes the current chart's timeframe in minutes and compares it against each MTF target: if the chart timeframe equals or exceeds the MTF, that oscillator is automatically hidden. This prevents false readings where a lower timeframe appears "never overbought" simply because its data has been averaged into a higher timeframe bar.

2. Three-Timeframe Alignment Signal with Consecutive Prevention
Star markers appear only when the current timeframe, 15-minute, and 1-hour WaveTrend oscillators are simultaneously in overbought or oversold territory. The signal fires only on the first bar where alignment occurs (not on every bar while aligned), preventing consecutive star markers. This three-specific-timeframe requirement means the alignment signal represents convergence across short-term (current), intermediate (15m), and structural (1hr) momentum — a more meaningful condition than simply checking two adjacent timeframes.

3. Extreme-Zone Crossover Filtering with Signal Counting
Standard WaveTrend crossover signals fire on every WT1/WT2 cross, producing many signals during trending conditions. This indicator tracks a boolean flag that is set when the oscillator enters an extreme zone (beyond overbought/oversold Level 1) and cleared when it returns to the normal range (inside Level 2). Crossover signals only fire while this flag is active. Additionally, a counter distinguishes the first crossover after entering the extreme zone from subsequent crossovers within the same extreme episode. These are displayed at different visual sizes (tiny vs small), allowing traders to distinguish initial reversal signals from follow-through signals.

4. Multi-Layer Gradient Fill System
The oscillator pane uses a layered fill architecture: a base gradient fill extends from the zero line toward WT1/WT2 with directional coloring, each MTF oscillator has its own fill between WT1 and WT2 with progressively decreasing transparency (50% for 1min, 40% for 5min, 30% for 15min, 20% for 1hr), and a foreground extreme zone fill highlights only the region beyond the overbought/oversold Level 1 lines. This layering creates a visual hierarchy where MTF fills provide background context and extreme zones draw immediate attention.

5. Optional MTF Smoothing
Higher timeframe WaveTrend data fetched via request.security() can optionally be post-processed with SMA, EMA, or Double EMA smoothing of configurable length. This reduces the "staircase" visual artifact common with raw MTF data, where values update in discrete steps at higher timeframe bar closes.


USAGE

Reading WaveTrend Signals
Each enabled timeframe displays its own WaveTrend WT1/WT2 oscillator lines. Overbought and oversold levels are marked with horizontal reference lines. When the WaveTrend crosses above the oversold level, it generates a bullish signal; when it crosses below the overbought level, it generates a bearish signal.

Alignment Signals
Star markers (★) appear when the current timeframe, 15-minute, and 1-hour oscillators simultaneously reach overbought or oversold conditions. Stars appear only on the first bar of alignment.

Crossover Signals
Crossover signals are filtered to only appear after the oscillator has been in an extreme zone. The first crossover after entering the zone appears as a tiny marker; subsequent crossovers within the same zone appear as small markers.

Auto-Hide
Oscillators from timeframes at or below the current chart timeframe are automatically hidden to prevent dampened readings.


DETAILS

WaveTrend Calculation
The WaveTrend oscillator is calculated in three steps:
1 — An EMA of the typical price (HLC3) is computed over the channel length
2 — The absolute deviation from this EMA is smoothed with another EMA of the same length
3 — The normalized difference CI = (HLC3 − ESA) / (0.015 × D) is smoothed with an EMA of the average length to produce WT1, and a simple SMA of WT1 produces WT2

For each higher timeframe, the full calculation is performed on that timeframe's data using request.security(), then both WT1 and WT2 values are brought down to the chart timeframe.

Auto-Hide Logic
The current chart timeframe is converted to minutes: timeframe.in_seconds() / 60. Each MTF input is conditionally disabled when current_tf_minutes >= mtf_minutes. This check runs on every bar, so the hiding is dynamic if the user changes chart timeframes.

Crossover State Machine
Two boolean flags (been_oversold, been_overbought) track whether the oscillator has entered extreme territory. Two counters (crossover_count_oversold, crossover_count_overbought) increment on each crossover while the flag is active. Flags and counters reset when the oscillator returns inside Level 2 (the buffer zone between normal and extreme). This state machine enables differentiation between initial and follow-through crossovers.


SETTINGS

WaveTrend
Channel Length: EMA period for the price channel (default: 9).
Average Length: EMA period for final smoothing (default: 12).
Overbought / Oversold Level: Threshold levels for signal generation.

Timeframes
Show 1m / 5m / 15m / 1H: Toggle each timeframe's display.
Timeframe Colors: Customizable colors for each oscillator line.

Signals
Show Alignment Stars: Display multi-TF alignment markers.
Show First Crossover / Subsequent Crossovers: Toggle crossover signal types independently.
Smooth Higher Timeframe Waves: Apply post-processing smoothing to MTF data.
Smoothing Type / Length: Choose SMA, EMA, or Double EMA with configurable period.


METHODOLOGY

The base WaveTrend algorithm is a known public-domain oscillator. The source code is protected because it contains the specific implementation of the systems built on top of it: (1) The timeframe hierarchy auto-hide logic that computes chart period in minutes and conditionally suppresses each MTF oscillator to prevent dampened extreme values. (2) The three-timeframe alignment detector with consecutive-bar prevention. (3) The extreme-zone crossover state machine with boolean flags, crossover counters, and dual-tier signal sizing. (4) The multi-layer gradient fill architecture with per-MTF transparency scaling and foreground extreme zone highlighting. These systems transform the standard WaveTrend from a single-timeframe oscillator into a multi-dimensional analysis framework.


This is an oscillator-based tool and does not constitute financial advice. Overbought and oversold conditions do not guarantee reversals. Past performance does not guarantee future results.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.