Oscillators
Momentum indicators that fluctuate between bounded values to identify overbought and oversold conditions. Oscillators help time entries and exits by measuring market momentum and potential reversal points.
Overview
RSI (Relative Strength Index)
Measures momentum by comparing recent gains to losses. Values oscillate between 0-100.
CCI (Commodity Channel Index)
Measures deviation from statistical mean to identify cyclical trends and extremes.
Stochastic Oscillator
Compares closing price to price range over time. Shows %K and %D lines.
Functions Reference
rsi - momentum oscillator (0-100)
rsi(source: TimeSeries, period: number, priceIndex?: number = 1): TimeSeries
Parameters:
- source (TimeSeries) - Source data for calculation
- period (number) - Number of periods (typically 14)
- priceIndex (number) - Index of price data (default: 1)
Returns:
TimeSeries (values 0-100)
Code Example:
_cci - Commodity Channel Index measures deviation from statistical mean
_cci(barIndex: number, series: TimeSeries, period?: number = 20, constant?: number = 0.015): number
Parameters:
- barIndex (number) - Current bar index
- series (TimeSeries) - Source data series
- period (number) - Number of periods (default: 20)
- constant (number) - Scaling constant (default: 0.015)
Returns:
number (CCI value, typically between -100 and +100)
Code Example:
_stochastic - Stochastic Oscillator compares closing price to price range
_stochastic(barIndex: number, series: TimeSeries, kPeriod?: number = 14, kSmoothing?: number = 3, dPeriod?: number = 3): [number, number]
Parameters:
- barIndex (number) - Current bar index
- series (TimeSeries) - Source data series
- kPeriod (number) - %K periods (default: 14)
- kSmoothing (number) - %K smoothing (default: 3)
- dPeriod (number) - %D periods (default: 3)
Returns:
[number, number] ([%K, %D] values between 0-100)
Code Example:
Common Usage Patterns
RSI Divergence Detection
Identify potential reversals when price and RSI move in opposite directions
Multi-Oscillator Confirmation
Combine multiple oscillators for stronger signal confirmation
Best Practices
Avoid False Signals
Oscillators can remain overbought/oversold for extended periods in strong trends. Always confirm with price action and trend direction.
Divergence Analysis
Look for divergences between price and oscillator. When price makes new highs/lows but oscillator doesn't, reversal may be coming.
Multiple Timeframes
Use oscillators on multiple timeframes. Higher timeframe signals are generally more reliable than lower timeframe signals.
Market Conditions
Oscillators work best in ranging markets. In strong trends, use them for timing entries rather than counter-trend trading.