Workshop #4: Technical Analysis III – Computational Technical Analytical Tools
Duration: ~1 hour | Instructor: Dr. Raymond Lee
Self-contained session on the most widely used computational indicators: Moving Averages, Bollinger Bands, RSI, and MACD. All examples use Python. No PPT required.
1. Moving Averages (15 min)
Moving averages smooth price fluctuations and reveal the underlying trend. Common types:
- Simple Moving Average (SMA) – Equal weight to every period. Easy to calculate but lags more.
- Exponential Moving Average (EMA) – More weight to recent prices; older data never completely disappears. More responsive than SMA.
- Weighted Moving Average (WMA) – Linearly increasing weights toward recent prices.
Common signals:
- Price above its MA → bullish bias; below → bearish bias (especially the 200-day SMA).
- Shorter MA crossing above longer MA → buy signal; reverse crossover → sell signal (e.g. 5/20, 13/34 Fibonacci, 4/9/18 triple crossover).
Popular lengths: 21-day (short-term), 50-day (intermediate), 200-day (long-term). Fibonacci-related lengths (13, 21, 34, 55…) are popular among many technicians.
There is no single “best” MA. Experiment with the security and time horizon you trade. EMA is generally more sensitive than SMA but less sensitive than WMA.
2. Bollinger Bands (15 min)
Developed by John Bollinger. Bands are placed a number of standard deviations (usually 2) above and below a simple moving average (usually 20 periods). The bands expand in high volatility and contract (“squeeze”) in low volatility.
- Most price action occurs inside the bands.
- A squeeze (narrow bands) often precedes a strong directional move.
- Closes outside a band indicate strong momentum; a subsequent close back inside can signal a reversal.
- Tops/bottoms formed outside the bands followed by tops/bottoms inside the bands often mark trend changes.
Tip: Bollinger Bands work best when combined with other indicators and price action. They are not a standalone system.
3. Relative Strength Index (RSI) (15 min)
Momentum oscillator developed by J. Welles Wilder (1978). Standard period is 14. Range is 0–100.
Interpretation methods:
- Extreme readings – Above 70 suggests overbought; below 30 suggests oversold (levels can be adjusted).
- Divergence – Price makes a new high/low but RSI does not → warning of potential reversal. Often more reliable than the 70/30 levels alone.
- Failure swings – RSI rises above 70, pulls back, fails to reach 70 again, then breaks the prior low (sell signal). Inverse for bottoms.
- Support/resistance and chart patterns can also be drawn on the RSI itself.
Tip: Do not treat RSI 70/30 as automatic sell/buy signals. Combine with trend direction and price action. A simple midpoint (50) cross strategy is also used by some traders.
4. MACD (10 min)
Moving Average Convergence-Divergence, developed by Gerald Appel. It is the difference between a fast EMA (typically 12) and a slow EMA (typically 26). This difference is further smoothed by a 9-period EMA called the signal line. A histogram shows the difference between the MACD line and the signal line.
- MACD line crossing above the signal line is considered bullish; crossing below is bearish.
- Divergence between MACD and price is the primary method of interpretation.
- Extreme MACD readings indicate overbought or oversold conditions.
Warning: MACD was not designed as a pure mechanical crossover system. Using only the crossover will produce many false signals. Always combine with divergence analysis and other tools.
5. Quick Python Illustration (optional live demo)
import yfinance as yf
import pandas as pd
data = yf.download("AAPL", period="1y", progress=False)
close = data["Close"]
# 20-day SMA and Bollinger Bands
sma20 = close.rolling(20).mean()
std20 = close.rolling(20).std()
upper = sma20 + 2 * std20
lower = sma20 - 2 * std20
# Simple RSI (14)
delta = close.diff()
gain = delta.clip(lower=0).rolling(14).mean()
loss = (-delta.clip(upper=0)).rolling(14).mean()
rs = gain / loss
rsi = 100 - 100 / (1 + rs)
print(rsi.tail())
Workshop Exercise
- What is the main practical difference between a Simple Moving Average and an Exponential Moving Average? When might you prefer one over the other?
- Describe what a Bollinger Band “squeeze” looks like and what it often signals. How can a trader use the subsequent breakout?
- Write the RSI formula. If the 14-day average gain is 1.2 and the average loss is 0.8, calculate the approximate RSI value. Is this overbought, oversold, or neutral?
- What is a bullish divergence on the RSI? Why is divergence often considered more reliable than simply reading the 30/70 levels?
- Using Python (yfinance + pandas), download 1 year of daily data for a stock of your choice. Compute a 20-day SMA and 20-day Bollinger Bands (2 standard deviations). Also compute a 14-day RSI. Plot or print the most recent 10 values of price, upper band, lower band, and RSI. Briefly comment on whether the stock currently looks overbought or oversold according to these indicators.
Submit your Python code + written answers.
QF Workshop #4 – Computational Finance | Dr. Raymond Lee