WaveTrend Oscillator for ThinkorSwim [LazyBear]

Can someone please help create two Thinkscript scanners based on this WaveTrend Oscillator from LazyBear?
Buy Signal Scanner 1: Scan for stocks where the WT1 (Green Line) just crossed ABOVE the WT2 (Red Dotted Line) for the FIRST time while both lines are BELOW minus 20 (-20)

Sell Signal Scanner 2: Scan for stocks where the WT1 (Green Line) just crossed UNDER the WT2 (Red Dotted Line) for the FIRST time while both lines are ABOVE 20
It should be The "first time in the last 3 bars"


add this code snippet to the bottom of your study:
def BuySig = wt1_1<-20 and wt2_1<-20 and wt1_1 crosses above wt2_1;
plot BuySigScan = !BuySig[1] and !BuySig[2] and BuySig; BuySigScan.hide();

def SellSig = wt1_1>20 and wt2_1>20 and wt1_1 crosses below wt2_1;
plot SellSigScan = !SellSig[1] and !SellSig[2] and SellSig; SellSigScan.hide();

Your scan filter will be:
BuySigScan is true
or
SellSigScan is true

Here is a tutorial for adding scan filters to the Scan Hacker:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

This is one of my first attempts at converting a Pine Script indicator into ThinkScript, and I wanted to start with something relatively simple to get the hang of it. I’ve always been interested in how indicators work under the hood, and working through the conversion process has been a great way to learn. Converting scripts really interests me, and I plan to keep practicing so I can improve my skills and eventually tackle more complex projects.

The original author of this script states:
WaveTrend Oscillator is a port of a famous TS/MT indicator.
When the Oscillator(Cyan line) is above the overbought band (red lines) and crosses down the signal (Yellow dotted line), it is usually a good SELL signal. Similarly, when the oscillator crosses above the signal when below the Oversold band (green lines), it is a good BUY signal.
Ruby:
# -----------------------
# WaveTrend Indicator by LazyBear
# Converted by TraderSam
# 08/30/25
# -----------------------

declare lower;

# === Inputs ===
input EMALength1 = 10;
input EMALength2 = 21;
input wt2Length = 4;
input oblevel1 = 60;
input oblevel2 = 53;
input oslevel1 = -60;
input oslevel2 = -53;
input showcloud = yes;
input showHistogram = no;

# === Basic Calculations ===
def AP = (high + low + close) / 3;  #HLC3
def EMA = Expaverage(ap, emalength1);
def dEMA = Expaverage(absValue(ap - EMA), EmaLength1);
def ci = (ap - ema) / (0.015 * dEMA);
def tci = expAverage(ci, emaLength2);

def wt1 = tci;
def wt2 = simpleMovingAvg(tci, wt2Length);
def diff = wt1 - wt2;

# === Plots ===
plot Zeroline = 0;
zeroline.setDefaultColor(color.gray);
zeroline.setLineWeight(3);

plot OB1 = oblevel1;
ob1.setDefaultColor(color.red);
ob1.setLineWeight(2);

plot ob2 = oblevel2;
ob2.setdefaultColor(color.red);
ob2.setStyle(curve.short_dash);
ob2.setlineWeight(1);

plot os1 = oslevel1;
os1.setdefaultColor(color.green);
os1.setlineWeight(2);

plot os2 = oslevel2;
os2.setDefaultColor(color.green);
os2.setStyle(curve.short_dash);
os2.setLineWeight(1);

plot wavetrend = wt1;
wavetrend.setdefaultColor(color.cyan);
wavetrend.setLineWeight(2);

plot signal = wt2;
signal.setdefaultcolor(color.yellow);
signal.setStyle(curve.short_dash);
signal.setlineweight(1);

# === clouds ===
AddCloud(if showCloud then wt1 else Double.NaN, if showCloud then wt2 else Double.NaN, CreateColor(80,140,255));

# === optional histogram ===
plot Histogram = if showHistogram then diff else Double.NaN;
Histogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Histogram.SetDefaultColor(Color.BLUE);
Histogram.SetLineWeight(2);
 
I’m wondering what you’re using WTO with? What kind of indicators complement it best?
 
Last edited:
I’m wondering what you’re using WTO with? What kind of indicators complement it best?

There are three types of behavior that drive price.
You need indicators from all three categories to see the full picture.
WaveTrend handles the local momentum behavior, but you still need tools for trend/structure and market regime to know when those momentum signals matter.

BehaviorIndicatorsDescription
Local Momentum & ExhaustionOscillators (WaveTrend, RSI, Stoch, CCI, MACD Histo)Measures local force: acceleration, deceleration, exhaustion, and short‑term sentiment flips.
Trend, Structure, and LocationMoving Averages & Key Levels (20/50/200 MAs, HTF MAs, Swing High/Low, VWAPs, PDH/PDL, Support/Resistance)Defines direction and location. Shows whether a WT signal has support, no support or is just mid-range noise
Regime, Volatility, Liquidity, ParticipationBreadth, RS Acceleration, Index Alignment, ATR Exp/Cont, Choppiness Index, RVOLDetermines the environment: whether momentum signals will follow through or fail, and whether trends will be clean or choppy.


CAUTION
Not all indicators are equal.

You are drawn to WaveTrend because it is forward-looking. It reacts to behavioral pressure, not just historical averages.
WaveTrend, Key Levels, and RS Acceleration are all behavior‑based and predictive in nature.
Most oscillators, moving averages, swings high/low are lagging because they are built entirely from historical data. They confirm what already happened, not what is building underneath the surface.
 
There are three types of behavior that drive price.
You need indicators from all three categories to see the full picture.
WaveTrend handles the local momentum behavior, but you still need tools for trend/structure and market regime to know when those momentum signals matter.

BehaviorIndicatorsDescription
Local Momentum & ExhaustionOscillators (WaveTrend, RSI, Stoch, CCI, MACD Histo)Measures local force: acceleration, deceleration, exhaustion, and short‑term sentiment flips.
Trend, Structure, and LocationMoving Averages & Key Levels (20/50/200 MAs, HTF MAs, Swing High/Low, VWAPs, PDH/PDL, Support/Resistance)Defines direction and location. Shows whether a WT signal has support, no support or is just mid-range noise
Regime, Volatility, Liquidity, ParticipationBreadth, RS Acceleration, Index Alignment, ATR Exp/Cont, Choppiness Index, RVOLDetermines the environment: whether momentum signals will follow through or fail, and whether trends will be clean or choppy.


CAUTION
Not all indicators are equal.

You are drawn to WaveTrend because it is forward-looking. It reacts to behavioral pressure, not just historical averages.

Great explanation, thank you!
I’ve been testing it along with MA Cloud and RVol, also making sure my trades align with market and sector breadth.
I think I’m on the right pass with this setup but still was curious how the others here use it.

Thanks again!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
1573 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top