ProIndicatr Pro: 4 Pro indicators
indicator.trading
All scripts

Free · Open source

Trend-Aware Oscillator

Overbought and oversold read in the direction of the trend – not against it.

Type
Oscillator with trend filter
Replaces
RSI · Stochastic
Recommended
4h and daily chart
Price
Free, open source
Open chart on TradingView
Trend-Aware Oscillator with RSI 14 and EMA 200 trend filter below the daily chart of the S&P 500 ETF SPY, with green trend background and pullback signals
Trend-Aware Oscillator with RSI 14 and EMA 200 trend filter below the daily chart of the S&P 500 ETF SPY, with green trend background and pullback signals

The Trend-Aware Oscillator takes a classic oscillator such as the RSI and puts it into the context of the trend. In an uptrend, “overbought” is shown as strength; in a downtrend, “oversold” is shown as weakness – and pullback signals only appear in the direction of the trend, long and short alike. You can choose from eight oscillators, all with the same trend logic. This page explains every element – and above all, what you do with it and why.

Overview

At a glance

What does it do?

It classifies every candle as uptrend, downtrend or no trend and reads the oscillator accordingly: extremes in the direction of the trend are strength, pullbacks against the trend are opportunities.

What do I do with it?

You look for entries in the direction of the trend when a pullback runs out – and you stop selling automatically just because the RSI is above 70.

Why?

In a trend, an oscillator often stays “overbought” or “oversold” for weeks. If you read that as a reversal signal, you keep trading against the stronger side.

What do I get?

A calmer, more logical picture: fewer trades against the trend and clearly marked moments when a pullback ends.

On your chart in 2 minutes

Quickstart

  1. 01

    Open the script page

    The TradingView button at the top of this page takes you straight to the script page. The script is free and open source.

  2. 02

    Add it to your favorites

    On the script page, click Add to favorites (the star icon).

  3. 03

    Add it to your chart

    At the top of the chart, click Indicators, choose Favorites on the left and click Trend-Aware Oscillator. Alternatively, search for “Indicatr” in the Indicators window.

  4. 04

    Pick a market and timeframe

    Start with a market that forms clear trends, for example the S&P 500, Nasdaq or Bitcoin, on the daily chart or on 4h. The default – RSI 14 with an EMA 200 trend filter – is fine to begin with.

The chart explained

What you see on the chart

Bitcoin, 4h. First an uptrend with several pullback longs, then from mid-October a downtrend with one pullback short. The numbers belong to the list below.Open chart on TradingView
All elements of the Trend-Aware Oscillator below a Bitcoin 4h chart, numbered
All elements of the Trend-Aware Oscillator below a Bitcoin 4h chart, numbered
  1. 1Green background Uptrend according to the trend filter. A white background means: no trend.
  2. 2Red background Downtrend according to the trend filter.
  3. 3Overbought / oversold The gray lines (70 and 30 for the RSI) with the neutral zone in between.
  4. 4Strength Overbought in an uptrend: the line turns strong green instead of becoming a sell signal.
  5. 5Weakness Oversold in a downtrend: the line turns strong red instead of becoming a buy signal.
  6. 6Pullback levels Dotted: red for the downtrend (60 for the RSI), green for the uptrend (40 for the RSI).
  7. 7Pullback long Green triangle at the bottom: a pullback in an uptrend is running out.
  8. 8Pullback short Red triangle at the top: a bounce in a downtrend is running out.

Elements 1 and 2

The trend regime

What does it do?

The trend filter assigns every candle to one of three states: uptrend (green background), downtrend (red background) or no trend (no background).

What do I do with it?

The background tells you which direction to look for entries in at all. Green: long ideas only. Red: short ideas only. White: wait or trade differently.

Why?

The same RSI value means something different in a trend than in a sideways phase. Only the trend tells you whether an extreme is more likely continuation or exhaustion.

What do I get?

You trade with the stronger side instead of against it – and you see immediately when the picture changes.

There are three trend filters. EMA (default): price above a rising EMA 200 is an uptrend, price below a falling EMA 200 is a downtrend. ADX / DMI: the ADX is above its threshold (default 20), and the direction comes from +DI and −DI. EMA + ADX: both have to agree – this gives fewer but cleaner trend phases.

Elements 3 to 5

Strength and weakness instead of overbought and oversold

The oscillator line takes on the color of the regime: green in an uptrend, red in a downtrend, gray without a trend. If the oscillator rises above the upper gray line in an uptrend, the line turns strong green – that’s strength, not a sell signal. If it drops below the lower line in a downtrend, it turns strong red – that’s weakness, not a buy signal.

Elements 6 to 8

Long and short pullback signals

A pullback long (green triangle at the bottom) forms in an uptrend when the oscillator drops below the green pullback level and rises back above it – for the RSI that’s 40. A pullback short (red triangle at the top) forms the mirrored way in a downtrend, when the oscillator rises above the red pullback level and drops back below it – 60 for the RSI. Each oscillator comes with its own matching levels, for example −70 and −30 for Williams %R.

The idea behind it: in a trend, the market corrects without reaching the extreme. In an uptrend, the RSI often doesn’t get anywhere near 30 but turns before. The signal comes at the moment the pullback loses momentum.

Classic signals without a trend (optional)

With Show classic OB/OS signals when no trend, the script marks the classic reversal points as gray circles in phases without a trend: at the bottom when the oscillator comes back out of the oversold area, at the top when it falls back out of the overbought area. It’s off by default.

Eight to choose from

Which oscillator should you use?

All eight oscillators use their standard formulas and the same trend logic. They differ in how fast they react and how many signals they deliver. The script sets the matching levels for each oscillator automatically.

OscillatorCharacterFits if you …
RSIThe classic. Calm and widely used.… want a solid default. A good starting point.
StochasticWhere is the close within the range of the last candles? Reacts faster than the RSI.… want earlier signals and accept more false signals.
Stochastic RSIThe Stochastic applied to the RSI. Very fast.… trade short-term. Often too restless on higher timeframes.
Williams %RSimilar to the Stochastic, scale from 0 to −100, unsmoothed.… like fast reactions.
CCIDistance from the average price, with no fixed upper or lower bound.… want to see how far price is from its mean.
MFIAn RSI that also takes volume into account.… trade markets with real volume: stocks, futures, large crypto exchanges.
WaveTrendSmoothed channel oscillator. Calmer, fewer signals.… prefer fewer but calmer signals.
Fisher TransformReshapes price moves so that turning points stand out clearly.… want to see turning points early and can handle spikes.

Don’t keep switching oscillators until one “fits”. Stick with one and learn how it behaves on your market.

Step by step

How to work with it

  1. 01

    Check the regime

    Look at the background. Green: you only look for longs. Red: only shorts. White: no trend – either wait or deliberately trade a range with the gray circles.

  2. 02

    Wait for the pullback

    In an uptrend, you wait until the oscillator drops below the green pullback level. No entry yet – the pullback can keep going.

  3. 03

    Wait for the signal

    The green triangle appears when the oscillator rises back above the level. Wait until the candle has closed.

  4. 04

    Check the price chart

    Is the pullback at a meaningful level – an old high, a support, the EMA? A signal in the middle of nowhere is weaker than one at a zone the market already knows.

  5. 05

    Set stop and size

    An obvious stop goes below the low of the pullback (for a short, above the high of the bounce). From the stop distance you calculate the position size – always the same risk per trade.

  6. 06

    Manage the trade

    A strong green line above 70 means: the trend is strong, no reason to panic. If the background turns white or red, that’s your warning to actively review the trade.

Before you take a pullback signal

  • Is the regime stable – or has it only just changed, or is it flipping back and forth?
  • Are there important events coming up? Central banks, jobs data, inflation, earnings for stocks.
  • Is there a major level right ahead of you where price has turned many times?
  • What are the related markets doing? For stocks bond yields and risk sentiment, for gold the dollar and real yields, for Bitcoin the general risk appetite.
  • Does the stop distance fit your risk?

Recommendations

Which markets fit – and which don’t

Pullback signals live on markets that form persistent trends and correct in an orderly way within them. The more often the regime changes, the less useful the trend logic is.

Good example: S&P 500 on the daily chart

S&P 500 (SPY), daily chart, RSI 14 with EMA 200 filter. Uptrend almost throughout: the RSI above 70 shows as strength, and the triangles mark pullbacks that turn back above 40.Open chart on TradingView
Trend-Aware Oscillator below the SPY daily chart: uptrend regime almost throughout, RSI above 70 as strength, several pullback longs
Trend-Aware Oscillator below the SPY daily chart: uptrend regime almost throughout, RSI above 70 as strength, several pullback longs

S&P 500 and Nasdaq

Daily chart, 4h

Good fit
  • Long upward phases: broad indices rise for years and often correct in an orderly way. Exactly the pattern pullback longs capture.
  • Very liquid: tight spreads, clean candles, few random spikes on the daily chart.
  • Tip: no new entries shortly before central-bank decisions and important US data – a data shock turns the oscillator in minutes.

Large-cap stocks and gold

Daily chart

Good fit
  • Large, liquid stocks follow long-term capital flows and form persistent trends. With real volume, the MFI works here too.
  • Gold often moves in one direction for months, driven by the dollar and real yields.
  • Careful with stocks: earnings create gaps that can jump over any stop.

Bitcoin

4h and daily chart

Good fit
  • Strong trends in both directions – ideal for using the short side as well (see the example above).
  • Traded around the clock, no overnight or weekend gaps.
  • Between the trends there are long sideways phases. The regime flips more often there – patience pays off.

Difficult example: GBP/NZD

GBP/NZD and similar crosses

for pullback signals

Poor fit
  • Sideways instead of trending: the pair often swings within a range for weeks. The regime changes frequently, and pullback signals come exactly when the trend is ending again.
  • Two central banks and a commodity currency pull in different directions – short spikes without follow-through.
  • Thin and expensive: wide spreads and no centralized volume. The MFI has no real basis here.
  • To be honest: for the classic gray circles in sideways phases, a swinging market like this can even fit better than a trending one. On small moves, though, the spreads eat a lot of the result.

EUR/USD and major forex pairs

Daily chart

Use with care
  • Very liquid, but trends form over weeks here, not hours. On the 4h chart the regime flips often.
  • On the daily chart the picture is much calmer.
  • Keep an eye on central-bank dates on both sides of the pair.

Which timeframe?

  • Daily chart: here the EMA 200 covers about 200 trading days – a long-term filter many market participants watch. Few, calm signals.
  • 4h: more signals, still easy to read. Good for Bitcoin, indices and gold.
  • 1h and below: the regime changes much more often, and costs weigh more. Only if you trade actively and know the bigger trend on the daily chart.

Both directions

Long and short

Bitcoin, 4h, detail. In the downtrend, the RSI rises above 60 and falls back below it: pullback short. Afterwards it drops below 30 – strong red, so weakness, not a buy signal.Open chart on TradingView
Bitcoin 4h detail: downtrend regime with red background, pullback short after the bounce above 60 and a strong red line below 30
Bitcoin 4h detail: downtrend regime with red background, pullback short after the bounce above 60 and a strong red line below 30

The logic is mirrored for both directions. In a downtrend, a bounce above the red pullback level is the opportunity for a short, and an RSI below 30 is weakness rather than a buying opportunity. Look at the two bounces at the end of October in the example: the RSI got to just below 60 and turned there – without crossing the level, there’s no signal.

The part that makes the difference

Practical tips

Before the entry

  • Don’t take every triangle. The best signals come in a stable regime and at a level the market knows.
  • A freshly changed regime is shaky. The first signals after a change are often less reliable than those in an established trend.
  • Check the calendar. Better to wait before big events.
  • Calculate position size from the stop – always the same risk per trade.

While the trade is running

  • Strength is not an exit. A strong green RSI above 70 in an uptrend means: it’s working. Take profits according to your plan, not because of a number.
  • Take regime changes seriously. When the background turns white or changes color, that’s the moment to actively review your trade.
  • Trail your stop below new pullback lows (for a short, above new bounce highs).

Don’t miss a thing

Setting up alerts

  1. 01

    Open the alert window

    At the top of the chart, click Alert or press Alt + A.

  2. 02

    Choose the condition

    Under Condition, select the Trend-Aware Oscillator and below it the alert you want.

  3. 03

    Trigger

    Choose “Once per bar close” so the alert only fires on the finished candle.

  4. 04

    Notification

    Choose app, email or webhook and save.

AlertWhen it fires
Trend pullback longPullback long in an uptrend (green triangle).
Trend pullback shortPullback short in a downtrend (red triangle).
Range long (classic)No trend: the oscillator comes back out of the oversold area.
Range short (classic)No trend: the oscillator falls back out of the overbought area.

Reference

All settings

Double-click the name “TAO [Indicatr]” at the top left of the indicator pane to open the settings. They are split into three groups. The defaults are enough to get started.

1 · Oscillator

Settings group 1: Oscillator
Settings group 1: Oscillator
OscillatorDefault: RSI
Which of the eight oscillators is shown. The pullback and extreme levels adjust automatically.
LengthDefault: 14
Lookback of the oscillator. Smaller = faster and more signals, larger = calmer and fewer signals.
Smoothing (Stoch / Stoch RSI / WaveTrend)Default: 3
Smoothing, only for these three oscillators. More smoothing calms the line but delays the signals.
Use custom levelsDefault: off
Off: the script uses the matching levels for the selected oscillator. On: your own values below apply.
Custom overbought / Custom oversoldDefault: 70 / 30
Your own extreme levels. Only active with Use custom levels.
Custom pullback level (downtrend) / (uptrend)Default: 60 / 40
Your own pullback levels for short and long signals. Closer to the middle = more, but shallower pullbacks get marked.

2 · Trend filter

Settings group 2: Trend filter
Settings group 2: Trend filter
Trend filterDefault: EMA
EMA: price and direction of the EMA. ADX / DMI: trend strength with direction from +DI/−DI. EMA + ADX: both have to agree – fewer but clearer trend phases.
EMA lengthDefault: 200
Length of the EMA. Shorter (e.g. 50) reacts earlier to trend changes but switches more often.
EMA slope lookback (bars)Default: 5
How many candles back the script checks whether the EMA is rising or falling. Larger = calmer regime, smaller = faster reaction.
ADX lengthDefault: 14
Lookback of the ADX. Only for ADX / DMI and EMA + ADX.
ADX trend thresholdDefault: 20
From this ADX value on, the market counts as trending. Higher = only strong trends, more phases without a trend.

3 · Signals & display

Settings group 3: Signals & display
Settings group 3: Signals & display
Show trend pullback signalsDefault: on
The green and red triangles in the direction of the trend.
Show classic OB/OS signals when no trendDefault: off
Gray circles for classic reversal points in phases without a trend. Useful if you deliberately trade ranges.
Shade background by trend regimeDefault: on
Green or red background depending on the regime. Turn it off if the pane is too colorful for you – the line color still shows the regime.
Uptrend / Downtrend / No trendDefault: Green / Red / Gray
Colors for the line, background and signals. On dark charts you can pick lighter shades.

From practice

Common mistakes

  • Trading against the regime. A long on a red background because the RSI is “oversold” is exactly the mistake this script is meant to prevent.
  • Selling strength. An RSI above 70 in an uptrend is not an exit signal.
  • Trading signals on the open candle. Until the candle closes, the triangle can disappear again.
  • Taking every triangle. Without looking at levels, events and the environment, a good context tool turns into a random generator.
  • Forgetting custom levels. With Use custom levels, your values still apply after switching oscillators – on a different scale that produces no signals or wrong ones.
  • Constantly switching oscillators. Swapping until the past looks good means optimizing for chance.

FAQ

Does the Trend-Aware Oscillator repaint?

Not on closed candles. On the current, still open candle, the line, background and signals can change until it closes. That’s why you should use “Once per bar close” for alerts.

Why don’t I see a signal even though the RSI was below 30?

Because the market was in a downtrend. There, an RSI below 30 is weakness, not a buy signal. Without a trend, classic signals only appear if you turn on Show classic OB/OS signals when no trend.

Which trend filter is best?

To start with, the EMA 200 – it’s easy to follow and watched by many market participants. EMA + ADX is stricter and gives fewer but clearer trend phases. Check on your market which filter shows the regime more calmly.

Does the script work on every market?

Technically yes. It fits best on markets with persistent trends, such as indices, large-cap stocks, gold and Bitcoin. The MFI needs real volume and says little on forex.

Can I see several oscillators at once?

Yes – add the script several times and set a different oscillator in each copy.

What does the script cost?

Nothing. The Trend-Aware Oscillator is free and open source on TradingView. You can look at the code and learn how it works.

How do you like Trend-Aware Oscillator?

Your vote tells us what to work on next.

Support

Report a problem or share feedback

Something off with the script, unclear in the docs, or you have an idea? Write to us. We reply by email.

Helps us check access or settings.

Only used to reply to you.

What is it about?

By sending, you agree that we use your details to handle your request. More in our privacy policy.

Trend-Aware Oscillator

Puts RSI and friends into trend context. Overbought in an uptrend shows as strength, oversold in a downtrend as weakness.

Open on TradingView

For educational and analytical purposes only. Not financial advice. Marks and signals are not recommendations to buy or sell. Past behavior is no guarantee of the future. Trading involves a risk of loss.

Trend-Aware Oscillator – Documentation & Guide | indicator.trading