OPEN-SOURCE SCRIPT

Trend-Aware Oscillator [Indicatr]

495
Trend-Aware Oscillator puts classic oscillators into the context of the prevailing trend. Overbought in an uptrend is shown as strength, oversold in a downtrend as weakness, and pullback signals are only marked in the direction of the trend - for long and short.

WHAT IT DOES
Oscillators such as RSI or Stochastic are often read as "overbought = sell, oversold = buy". In trending markets this reading fails: an oscillator can stay overbought for weeks in an uptrend and oversold for weeks in a downtrend. This script adds a trend regime and changes how readings are coloured and signalled.

HOW IT WORKS
  1. Choose one oscillator: RSI, Stochastic, Stochastic RSI, Williams %R, CCI, MFI, WaveTrend or Fisher Transform. All use their standard formulas.
  2. Trend filter classifies every bar as uptrend, downtrend or no trend:
    EMA - price above a rising EMA (default 200) = uptrend, below a falling EMA = downtrend.
    ADX / DMI - ADX above the threshold with +DI above -DI = uptrend, the opposite = downtrend.
    EMA + ADX - both must agree.
  3. Uptrend: overbought readings are coloured as strength, not as a sell signal. A trend pullback long (green triangle) is marked when the oscillator dips below the uptrend pullback level and crosses back above it.
  4. Downtrend: oversold readings are coloured as weakness, not as a buy signal. A trend pullback short (red triangle) is marked when the oscillator rises above the downtrend pullback level and crosses back below it.
  5. No trend: classic overbought/oversold reversal marks can optionally be shown (grey circles).

Each oscillator has its own default levels, e.g. RSI 70/30 with pullback levels 60/40, Williams %R -20/-80 with -30/-70. Custom levels can be set in the inputs.

HOW TO USE
  • Use it as a context tool: is an extreme reading more likely continuation or exhaustion, given the trend?
  • Combine the pullback marks with your own entry rules, levels and risk management.
  • Alerts: trend pullback long, trend pullback short, range long, range short.


THE CHART
BTCUSD daily with RSI 14 and the EMA 200 trend filter. Red background = downtrend regime, green background = uptrend regime. In the downtrend phase the red triangles mark RSI rejections from the 60 level (pullback short). After the regime turns up, RSI above 70 is coloured as strength instead of an exit signal.

WHAT IS ORIGINAL
The built-in oscillators show readings without context. This script adds a selectable trend regime, regime-dependent colouring (strength/weakness instead of overbought/oversold), oscillator-specific pullback levels and symmetric long/short pullback logic. Combining eight oscillators in one script is intentional: the same trend logic is applied to interchangeable momentum sources so they can be compared on equal terms.

CREDITS
RSI and ADX/DMI (J. Welles Wilder), Stochastic (George Lane), Williams %R (Larry Williams), CCI (Donald Lambert), MFI (Gene Quong and Avrum Soudack), Fisher Transform (John Ehlers). The WaveTrend calculation follows the community version popularised on TradingView by LazyBear; it is re-implemented here and credited accordingly.

LIMITATIONS
  • The trend filter lags by design - regime changes are confirmed after the move has started.
  • In choppy markets the regime can switch often.
  • Signals can appear and disappear on the current, unclosed bar.


Disclaimer
For educational and analytical purposes only. Not financial advice. Marks and signals are not buy or sell recommendations. Past behaviour does not guarantee future results.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。