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 = 14, priceIndex?: number = 1): number
Parameters:
- source (TimeSeries) - Source data for calculation
- period (number) - Number of periods (default: 14)
- priceIndex (number) - Index of price data (default: 1)
Returns:
number (RSI value 0-100 for current bar)
Code Example:
cci - Commodity Channel Index measures deviation from statistical mean
cci(source: TimeSeries, period?: number = 20, constant?: number = 0.015): number
Parameters:
- source (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(source: TimeSeries, kPeriod?: number = 14, kSmoothing?: number = 3, dPeriod?: number = 3): [number, number]
Parameters:
- source (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:
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.