OPEN-SOURCE SCRIPT

CandelaCharts - Trend Oscillator

131
📝 Overview

Trend Oscillator is a simple yet effective trend identification tool that uses the relationship between two exponential moving averages (EMAs) to determine market direction. It calculates the spread between a fast and slow EMA, applies a bias multiplier, and smooths the result to produce a clean oscillator that oscillates above and below a zero line. When the oscillator is above zero, the trend is considered bullish (upward); when below zero, it's bearish (downward). The indicator provides clear visual feedback through color-coded plots and optional price bar coloring, making it easy to identify trend direction at a glance.

📦 Features

This section highlights the core capabilities you'll rely on most.
  • Dual EMA system — Uses a fast EMA (default 9) and slow EMA (default 21) to capture trend momentum and direction.
  • Bias multiplier — Applies a small multiplier (default 1.001) to the EMA spread, providing a slight bias that helps filter noise and confirm trend strength.
  • Smoothed output — Applies an additional EMA smoothing (default 5 periods) to the raw spread, creating a cleaner, less choppy oscillator line.
  • Zero-line reference — Plots a horizontal zero line that serves as the critical threshold between bullish and bearish conditions.
  • Color-coded visualization — Automatically colors the oscillator line green/lime when bullish (above zero) and red when bearish (below zero).
  • Price bar coloring — Optional feature to color price bars based on the current trend direction, providing immediate visual context on the main chart.
  • Customizable parameters — Adjust EMA lengths, bias multiplier, smoothing period, and colors to match your trading style and timeframe.


⚙️ Settings

Use these controls to fine-tune the oscillator's sensitivity, appearance, and behavior.
  • Fast EMA Length — Period for the fast exponential moving average (default: 9). Lower values make the indicator more responsive to price changes.
  • Slow EMA Length — Period for the slow exponential moving average (default: 21). Higher values create a smoother baseline for trend identification.
  • Bias Multiplier — Multiplier applied to the EMA spread (default: 1.001). Small adjustments can help filter minor whipsaws and confirm trend strength.
  • Smoothing Length — Period for smoothing the raw spread calculation (default: 5). Higher values create a smoother oscillator line but may lag price action.
  • Colors — Set the bullish (default: lime) and bearish (default: red) colors for the oscillator line.
  • Color Price Bars — Toggle to enable/disable coloring of price bars based on the current trend direction.


⚡️ Showcase

Oscillator Line
syot kilat

Bar Coloring
syot kilat

Divergences
syot kilat

📒 Usage

Follow these steps to effectively use Trend Oscillator for trend identification and trading decisions.
  • 1) Select your timeframe — The indicator works across all timeframes, but higher timeframes (daily, weekly, monthly) typically provide more reliable trend signals with less noise. Lower timeframes (1m, 5m, 15m) may produce more frequent but potentially less reliable signals. Consider your trading style: swing traders benefit from daily/weekly charts, while day traders can use 15m/1h timeframes. Always align the indicator's sensitivity with your timeframe choice.
  • 2) Adjust EMA lengths — The default 9/21 combination works well for most cases. For faster signals, try 5/13; for slower, more conservative signals, try 12/26 or 20/50. Match the lengths to your trading style and timeframe.
  • 3) Interpret the zero line — When the oscillator is above zero (green/lime), the trend is bullish. When below zero (red), the trend is bearish. The further from zero, the stronger the trend.
  • 4) Watch for crossovers — Trend changes occur when the oscillator crosses the zero line. A cross from below to above indicates a shift to bullish; from above to below indicates a shift to bearish.
  • 5) Identify divergences — Divergences can signal potential trend reversals. Bullish divergence: price makes lower lows while the oscillator makes higher lows (suggests weakening bearish momentum). Bearish divergence: price makes higher highs while the oscillator makes lower highs (suggests weakening bullish momentum). Divergences are most reliable when they occur near extreme levels and should be confirmed with price action before taking trades.
  • 6) Use smoothing wisely — The smoothing parameter helps reduce noise but adds lag. Lower smoothing (3-5) is more responsive; higher smoothing (7-10) is more stable but slower to react.
  • 7) Combine with price action — Use the oscillator to confirm trend direction, then look for entry opportunities when price pulls back in the direction of the trend. The optional price bar coloring helps visualize trend alignment on the main chart.
  • 8) Filter with bias multiplier — The bias multiplier can help reduce false signals. Experiment with values between 1.000 and 1.005 to find the sweet spot for your instrument and timeframe.


🚨 Alerts

There are no built-in alerts in this version.

⚠️ Disclaimer

Trading involves significant risk, and many participants may incur losses. The content on this site is not intended as financial advice and should not be interpreted as such. Decisions to buy, sell, hold, or trade securities, commodities, or other financial instruments carry inherent risks and are best made with guidance from qualified financial professionals. Past performance is not indicative of future results.

Penafian

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.