Academy/Foundations/Technical Indicators: Tools for Signal Generation
FoundationsLesson 4

Technical Indicators: Tools for Signal Generation

Master the essential technical indicators used in algorithmic trading: moving averages, RSI, Bollinger Bands, and MACD.

12 minute read
4 key takeaways

Essential Technical Indicators

Technical indicators are mathematical calculations based on price and volume that help identify trends, reversals, and momentum. They're the building blocks of most algorithmic trading signals.

Simple Moving Average (SMA)

SMA(n) = (P₁ + P₂ + ... + Pₙ) / n

Sum of last n closing prices divided by n

SMA smooths out daily price noise to show the underlying trend. A rising SMA means the market is moving higher on average. A falling SMA means lower on average.

python
df['SMA_20'] = df['Close'].rolling(window=20).mean()  # 20-day SMA
df['SMA_50'] = df['Close'].rolling(window=50).mean()  # 50-day SMA

# Golden cross: SMA_20 crosses above SMA_50 (bullish signal)
df['Signal'] = 0
df.loc[df['SMA_20'] > df['SMA_50'], 'Signal'] = 1  # Buy
df.loc[df['SMA_20'] < df['SMA_50'], 'Signal'] = -1  # Sell

Exponential Moving Average (EMA)

Like SMA but gives more weight to recent prices. Reacts faster to price changes than SMA.

EMA_t = α × P_t + (1-α) × EMA_{t-1}, where α = 2/(n+1)

Recursive formula weighted toward recent prices

RSI: Relative Strength Index

RSI = 100 - 100/(1 + RS), where RS = Avg Gain / Avg Loss

Measures momentum on 0-100 scale

RSI ranges from 0 to 100. RSI > 70 = overbought (potential sell). RSI < 30 = oversold (potential buy).

python
def calculate_rsi(prices, period=14):
    deltas = prices.diff()
    seed = deltas[:period+1]
    up = seed[seed >= 0].sum() / period
    down = -seed[seed < 0].sum() / period
    rs = up / down
    rsi = 100 - 100 / (1 + rs)
    return rsi

df['RSI'] = df['Close'].rolling(window=14).apply(
    lambda x: calculate_rsi(x, 14), raw=False
)

Bollinger Bands

Middle = SMA(20), Upper = SMA + 2σ, Lower = SMA - 2σ

SMA ± 2 standard deviations

Bands expand when volatility increases, contract when volatility decreases. Price touching upper band = overbought. Price touching lower band = oversold.

MACD: Moving Average Convergence Divergence

MACD = EMA(12) - EMA(26), Signal Line = EMA(9) of MACD

Difference between two exponential moving averages

MACD crossover: When MACD line crosses above signal line = bullish. Below signal line = bearish.

Indicators Are Lagging

All technical indicators are based on past prices. They react to moves that have already happened. Don't expect perfect entry points. Combine multiple indicators for confirmation.

See Indicators in the Trading Lab

Try using these indicators in a strategy

Key Takeaways
  • Moving averages smooth price data to identify trends
  • RSI measures momentum on a 0-100 scale
  • Bollinger Bands show volatility and overbought/oversold levels
  • Indicators are lagging—they react to prices that already moved