Strategy · Pine Script v4 · Own pane

WaveTrend with Crosses [LazyBear]

by avatar-lavventura· code credited to lavventura

This strategy calculates the WaveTrend oscillator using exponential moving averages of typical price and plots two signal lines alongside overbought and oversold thresholds in a separate pane.

View on GitHub

GitHub stars2on the repository
Pine versionv4older, still runs
Lines of code81
Settings12inputs
LicenceNone statedfile: MPL-2.0
Last update7 months ago5 Mar 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

81 lines of Pine Script v4 from pine/work/wt_version4.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

wt_version4.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © lavventura

//@version=4
//
// @author LazyBear
//
// If you use this code in its original/modified form, do drop me a note.
//
strategy(title="WaveTrend with Crosses [LazyBear]", shorttitle="WT_CROSS_LB", initial_capital=1000,currency=currency.USD,default_qty_type=strategy.percent_of_equity, default_qty_value=100)
n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")
obLevel1 = input(60, "Over Bought Level 1")
obLevel2 = input(53, "Over Bought Level 2")
osLevel1 = input(-60, "Over Sold Level 1")
osLevel2 = input(-53, "Over Sold Level 2")

ap = hlc3
esa = ema(ap, n1)
d = ema(abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ema(ci, n2)

wt1 = tci
wt2 = sma(wt1,4)

plot(0, color=gray)
plot(obLevel1, color=red)
plot(osLevel1, color=green)
plot(obLevel2, color=red)
plot(osLevel2, color=green)

plot(wt1, color=green)
plot(wt2, color=red)
plot(wt1-wt2, color=blue, style=area, transp=80)

plot(cross(wt1, wt2) ? wt2 : na, color = color.black , style=shape.circle, linewidth = 3)
plot(cross(wt1, wt2) ? wt2 : na, color = (wt2 - wt1 > 0 ? color.red:color.lime) , style = shape.circle, linewidth = 2)

barcolor(cross(wt1, wt2) ? (wt2 - wt1 > 0 ? color.aqua:color.yellow) : na)

// --------------------------------------------------
wt1_past = wt1[1]
wt2_past = wt2[1]

divlong = wt1 > wt2 and wt1_past < wt2_past and wt1_past < osLevel2
divshort = wt1 < wt2 and wt1_past > wt2_past and wt1_past > obLevel2

data1 = divlong
plotshape(data1, style=shape.xcross,location=location.bottom, color=color.green, size = size.tiny, title="WT_up")

data2 = divshort
plotshape(data2, style=shape.xcross,location=location.top, color=color.red, size = size.tiny, title="WT_down")
plotshape(data1 or data2, style=shape.xcross,location=location.absolute, color=color.gray, title="WT_BOTH")
//
plot(cross(wt1, wt2) ? wt2 : na, color=color.black,style = shape.circle, linewidth = 3)
plot(cross(wt1, wt2) ? wt2 : na, color=(wt2 - wt1 > 0 ? color.red:color.lime) , style=shape.circle, linewidth = 2)
//

fromYear = input(2020, "Backtest Start Year")
fromMonth = input(1, "Backtest Start Month")
fromDay = input(2, "Backtest Start Day")
testPeriodStart = timestamp(fromYear,fromMonth,fromDay,0,0)

thruYear = input(2021, "Backtest Stop Year")
thruMonth = input(12, "Backtest Stop Month")
thruDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(thruYear,thruMonth,thruDay,0,0)

start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)  // backtest start window
finish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)  // backtest finish window
window()  => time >= start and time <= finish ? true : false

divcrosslong  = wt1 - wt2 < 0
divcrossshort = wt1 - wt2 > 0

strategy.entry("Long", strategy.long, when=window() and divlong)
strategy.close("Long", when=window() and divcrosslong)

strategy.entry("Short",strategy.short, when=window() and divshort)
strategy.close("Short", when=window() and divcrossshort)

Overview

WaveTrend with Crosses [LazyBear] enters long positions when the primary line crosses above the signal line in oversold territory, and enters short positions on bearish crosses in overbought territory during a configured backtest window. Long trades close when the fast line falls below the slow line, while short trades exit on opposite crosses. Inputs adjust smoothing lengths, threshold levels, and date ranges. Sizing defaults to full equity, and trades lack a stop loss.

Details

Published by

avatar-lavventura on GitHub

Code credit

lavventura, as written in the script's header

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Moving averages, Mean reversion

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Channel Lengthint10n1
Average Lengthint21n2
Over Bought Level 1int60obLevel1
Over Bought Level 2int53obLevel2
Over Sold Level 1int-60osLevel1
Over Sold Level 2int-53osLevel2
Backtest Start Yearint2020fromYear
Backtest Start Monthint1fromMonth
Backtest Start Dayint2fromDay
Backtest Stop Yearint2021thruYear
Backtest Stop Monthint12thruMonth
Backtest Stop Dayint30thruDay
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

106 stars

Buy The Dips - MA200 Optimised is a mean-reversion strategy that measures short-term percentage price changes alongside a simple moving average trend filter. It opens long positions when price experiences a steep drop exceeding three percent while remaining ab

Strategy v4 Oscillators & momentumTrend
Updated 2 years ago · GPL-3.0 GitHub repository of Buy The Dips - MA200 Optimised

Greeffer BB Strategy

by SammyEnigma
18 stars

This strategy combines Bollinger Bands, Bollinger Band Width, and the Relative Strength Index (RSI) for mean-reversion trades. It enters long when price crosses below the lower band with oversold RSI, or when band width contracts under low volatility. Short en

Strategy v4 Mean reversionOscillators & momentum
Updated 6 years ago · None stated GitHub repository of Greeffer BB Strategy
2 stars

This strategy plots in a separate pane and tests a selected oscillator with one of six entry logics: moving average, moving-average crossover, zero cross, extremes, mean reversion, or take profit. Users scale and time-adjust one of three oscillators and can li

Strategy v4 Oscillators & momentumMoving averages
Updated 8 months ago · None stated GitHub repository of Oscillator Evaluator (Analysis tool)

Oversold

by kat3samsin
2 stars

The oversold strategy identifies oversold conditions using the relative strength index with a 14 period. It applies an arithmetic linear moving average with a 20 period for trend filtering and requires the price to stay within 15 percent of this average. Stoch

Strategy v4 Mean reversionOscillators & momentum
Updated 5 years ago · MIT GitHub repository of Oversold
1 stars

The script calculates the yield spread between long-term and short-term US Treasury yields (T10Y2Y or manual US10Y minus US02Y) and plots the spread line on a separate pane. It signals long entries on steepening beyond a user threshold in reversion mode or SMA

Strategy v6 Mean reversionSupport & resistance
Updated 2 months ago · None stated GitHub repository of TN Yield Spread Sovereign v6
330 stars

This mean-reversion strategy combines multi-timeframe exponential moving averages, Bollinger Bands, and the Relative Strength Index. It generates long and optional short trade signals when price interacts with the Bollinger Bands alongside RSI threshold confir

Strategy v5 Mean reversionMoving averages
Updated 2 months ago · None stated GitHub repository of MEMA + BB + RSI [Alorse]

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers