On this page
- What WaveTrend measures
- The calculation in Pine Script
- Default entry and exit rules
- Parameter tuning
- Pine v5 vs v6 notes
- Free download and how to add it to a chart
- FAQ
What WaveTrend measures
WaveTrend is a momentum oscillator. It asks how far the typical price (hlc3, the average of high, low and close) has stretched away from its own exponential average, measured in units of recent average deviation. That makes the reading comparable across symbols and volatility regimes: a value near zero means price is sitting on its average, and a large positive or negative value means price has stretched far from it.
The signal comes from two lines. WT1 is the smoothed stretch reading. WT2 is a short simple average of WT1, so it lags. When WT1 crosses WT2 the oscillator is turning. A turn that happens far from zero (deep oversold or overbought) is what mean-reversion traders look for, which is why the strategy only trades crosses inside the outer bands by default.
The calculation in Pine Script
The indicator below is the full WaveTrend calculation with the same defaults as the AlgoVault strategy. It is written with //@version=6 syntax; the maths is identical in v5.
//@version=6
indicator("WaveTrend sketch", overlay = false)
n1 = input.int(10, "Channel length", minval = 1)
n2 = input.int(21, "Average length", minval = 1)
ob = input.float(53.0, "Overbought level")
os = input.float(-53.0, "Oversold level")
ap = hlc3
esa = ta.ema(ap, n1) // EMA of typical price
d = ta.ema(math.abs(ap - esa), n1) // EMA of absolute deviation
ci = d > 0 ? (ap - esa) / (0.015 * d) : na // channel index
wt1 = ta.ema(ci, n2) // main line
wt2 = ta.sma(wt1, 4) // signal line
plot(wt1, "WT1", color.teal)
plot(wt2, "WT2", color.orange)
hline(ob, "Overbought")
hline(0, "Zero")
hline(os, "Oversold")
bullCross = ta.crossover(wt1, wt2) and wt1 <= os
bearCross = ta.crossunder(wt1, wt2) and wt1 >= ob
plotshape(bullCross, "Bull cross", shape.circle, location.bottom, color.teal, size = size.tiny)
plotshape(bearCross, "Bear cross", shape.circle, location.top, color.orange, size = size.tiny)The constant 0.015 is a scaling factor inherited from the CCI family of indicators; it keeps most readings inside roughly ±100 on typical data. The d > 0 guard avoids a divide-by-zero on perfectly flat bars.
Default entry and exit rules
The strategy version wraps those lines in an execution engine. With default settings:
- Long: WT1 crosses above WT2 and WT1 is at or below -53.
- Short: WT1 crosses below WT2 and WT1 is at or above +53.
- Stop: 2 × ATR(14) from the entry reference by default (ATR, percent, structure or none are selectable).
- Target: 2R by default (R-multiple, ATR, percent, structure or none), with optional TP1/TP2/TP3 partials.
- Sizing: risk 1% of equity per trade, capped by a 5× leverage input.
- Exit signal: an opposite entry signal can close the open trade.
Why it does not repaint
Decisions are made on confirmed bars only and orders fill on the next bar open (calc_on_every_tick = false, process_orders_on_close = false). There is no request.security call and no lookahead. What you see in the Strategy Tester is what a live chart would have done bar by bar. The backtesting guide explains why this matters.
Parameter tuning
Change one input at a time and re-run the Strategy Tester on the same symbol, timeframe and date range, so you know which change caused which effect. These are the inputs that matter most and what they do directionally.
| Input (default) | What it controls | Raising it tends to… | Lowering it tends to… |
|---|---|---|---|
Channel Length (10) | Smoothing of the price average and the deviation | Smooth the oscillator and delay turns | Make it twitchier with more false crosses |
Average Length (21) | Smoothing of WT1 itself | Reduce signal count, lag entries | Increase signal count and noise |
OB / OS levels (±53, ±60) | How stretched price must be before a cross counts | (Moving the bands outward) filter to rarer, deeper extremes | (Moving the bands inward) allow more, shallower signals |
Only Cross Beyond Level 2 (on) | Whether crosses far from the extremes are traded | Turning it off turns the strategy into a plain WT1/WT2 cross system | Leaving it on keeps it a mean-reversion filter |
ATR Stop Multiplier (2.0) | Distance of the initial stop | Survive more noise, but each loss is bigger relative to position size | Smaller losses but more stop-outs |
Single Target R (2.0) | Profit target as a multiple of initial risk | Fewer winners reach the target | More winners, each smaller |
A sensible tuning workflow
- Pick the symbol and timeframe you actually intend to trade. Do not tune on one and trade another.
- Set realistic commission and slippage in
strategy()first. A WaveTrend setup on a low timeframe can look fine at zero cost and fail at real cost. - Tune the oscillator lengths and levels on the first part of your data only (for example, the older 60–70%).
- Freeze the settings, then run them on the untouched recent data. If results fall apart out of sample, the tuned numbers were fitted to noise.
- Prefer a plateau over a peak: if a neighbouring setting (11 instead of 10, 20 instead of 21) behaves similarly, the idea is robust. If only one exact value works, be suspicious.
- Check the trade count. A handful of trades says very little regardless of how the equity curve looks.
Pine v5 vs v6 notes
TradingView runs both versions side by side. The free WaveTrend script is written in Pine Script v5. If you want to move your own copy to v6, the Pine Editor has a convert option in its menu. After converting, re-read the script and re-run it, because v6 changed a few behaviours worth knowing about:
- Numbers are no longer implicitly cast to
bool, so conditions likeif someIntmust become explicit comparisons. and/ornow short-circuit, which can change behaviour if a right-hand expression has side effects.- A
boolcan no longer bena. - The deprecated
whenparameter onstrategy.*order functions is gone; wrap the call in anif.
For AlgoVault files that already target v6 see HTF Sweep CISD Strategy ($149) and Smart Money Concepts Suite ($189).
Free download and how to add it to a chart
- Open the WaveTrend Oscillator Strategy on TradingView and choose Add to chart. Alternatively copy the source from the AlgoVault product page into the Pine Editor, save, and add it.
- Open the Strategy Tester tab and read the Overview, List of Trades and Performance Summary.
- Open the strategy settings and set commission and slippage to match your broker before drawing any conclusion.
- Optional: create an alert from the strategy; alerts fire once per bar close and the message includes the stop and first target.
WaveTrend Oscillator Strategy Pack
Classic hlc3 EMA channel oscillator with WT1 / WT2 crosses inside the overbought and oversold bands.
The free pack also includes a standalone Python module for MetaTrader 5 that runs in dry-run mode by default. If you want to go further than one oscillator, Volume-Weighted Dual-Timeframe CCI Pack ($24) applies a related CCI idea with a volume and higher-timeframe filter, and the Complete Strategy Vault Bundle ($149) gives you every Classic pack under one licence.
FAQ
Is the WaveTrend Oscillator Strategy free on TradingView?
Yes. The AlgoVault WaveTrend Oscillator Strategy is published as a free, open-source script on TradingView. You can add it to a chart from the script page without paying anything. The MetaTrader 5 Python companion is a free download on AlgoVault.
Does the WaveTrend strategy repaint?
No. Signals are evaluated only on a confirmed bar close (barstate.isconfirmed) and orders fill on the next bar open. The script does not call request.security with lookahead, so history and live behaviour match.
Is the script Pine Script v5 or v6?
The free WaveTrend script is written in Pine Script v5, which TradingView still runs. The oscillator maths in this guide is plain Pine and works the same in v6. If you want a v6 copy, the Pine Editor can convert the code, then you re-check it compiles and behaves the same.
What timeframe works best for WaveTrend?
There is no universally best timeframe. The defaults (10 and 21) are a common starting point. Lower timeframes produce more signals and more cost drag; higher timeframes produce fewer, slower signals. Test the timeframes you actually trade, with realistic commission and slippage.