Technical Indicators with Python — Core Concepts

What technical indicators actually measure

Technical indicators transform raw price and volume data into derived signals that highlight trends, momentum, volatility, or overbought/oversold conditions. They fall into four broad families:

  • Trend indicators — show direction (moving averages, MACD)
  • Momentum indicators — show speed of price change (RSI, Stochastic Oscillator)
  • Volatility indicators — show how much prices fluctuate (Bollinger Bands, ATR)
  • Volume indicators — confirm moves with trading activity (OBV, VWAP)

Most traders combine indicators from different families to avoid redundant signals. Using two trend indicators together tells you the same thing twice.

The essential indicators

Moving Averages (SMA and EMA)

The Simple Moving Average is the arithmetic mean of the last N prices. The Exponential Moving Average gives more weight to recent prices, making it react faster.

Traders watch crossovers: when a short-period average crosses above a long-period one, it suggests upward momentum — and vice versa. The “golden cross” (50-day crossing above 200-day) and “death cross” (the opposite) are widely followed signals.

RSI — Relative Strength Index

RSI measures the ratio of recent up moves to down moves, scaled from 0 to 100. Values above 70 suggest a stock may be overbought; below 30, oversold. Created by J. Welles Wilder in 1978, it remains one of the most referenced indicators.

MACD — Moving Average Convergence Divergence

MACD tracks the difference between a 12-period EMA and a 26-period EMA. A separate “signal line” (9-period EMA of the MACD) acts as a trigger. When MACD crosses above the signal line, it is a bullish signal.

Bollinger Bands

A middle band (20-day SMA) with upper and lower bands set at two standard deviations. When prices touch the upper band, the market may be overextended; when they touch the lower band, it may be oversold. The band width itself signals volatility — narrow bands often precede large moves.

ATR — Average True Range

ATR measures the average daily range (including gaps from close to open). It does not indicate direction — only how much a stock typically moves. Traders use it to set stop-loss distances: a stop at 2× ATR gives the position room to breathe without being triggered by normal noise.

Computing indicators in Python

The pandas-ta library provides over 130 indicators in a single consistent API:

import pandas as pd
import pandas_ta as ta

# Assume df has columns: open, high, low, close, volume
df.ta.sma(length=20, append=True)
df.ta.rsi(length=14, append=True)
df.ta.macd(fast=12, slow=26, signal=9, append=True)
df.ta.bbands(length=20, std=2, append=True)
df.ta.atr(length=14, append=True)

For learning purposes, computing them manually reveals the math:

def rsi(prices: pd.Series, period: int = 14) -> pd.Series:
    delta = prices.diff()
    gain = delta.clip(lower=0)
    loss = -delta.clip(upper=0)
    avg_gain = gain.rolling(period).mean()
    avg_loss = loss.rolling(period).mean()
    rs = avg_gain / avg_loss
    return 100 - (100 / (1 + rs))

Common misconception

Many beginners treat indicator signals as certainties — “RSI says oversold, so I should buy.” Indicators describe probabilities, not guarantees. An RSI below 30 during a market crash can stay below 30 for weeks as the price keeps falling. Context matters more than any single number.

Choosing the right indicator for the situation

Market conditionUseful indicatorsWhy
Strong trendMoving averages, MACDConfirm direction and momentum
Range-boundRSI, StochasticIdentify overbought/oversold extremes
Pre-breakoutBollinger Bands, ATRDetect compression before a big move
High volatilityATR, Keltner ChannelsSize positions appropriately

The best approach: pick one indicator from each family and learn it deeply rather than adding a dozen indicators to your chart.

The one thing to remember: Technical indicators are tools for summarizing price behavior — combining one trend, one momentum, and one volatility indicator covers most of what you need without cluttering your analysis.

pythonfinancetechnical-analysistrading

See Also