Indicators & Oscillators
Chapter: 3.4 Indicators & Oscillators Level: 3 — Production (from-scratch derivations, code-from-memory, explain-out-loud) Time limit: 45 minutes Total marks: 60
Instructions: Show all working. Where code is requested, pseudocode or Python is acceptable but formulas must be explicit. Round to 2 decimals unless stated.
Question 1 — EMA from scratch (10 marks)
(a) Derive the EMA smoothing multiplier for a period and state the recursive update formula. (3)
(b) Given the closing prices [10, 11, 12, 13, 14], seed the EMA with the first value () and compute for a 3-period EMA. Show each step. (5)
(c) Explain out loud (2–3 sentences) why EMA reacts faster to price changes than an SMA of the same period. (2)
Question 2 — RSI derivation (12 marks)
(a) Write the RSI formula in terms of average gain and average loss, and the ratio. (3)
(b) Given these 7 consecutive daily closes [44, 44.5, 44.2, 45, 46, 45.5, 46.5], compute the 6-period RSI using simple averages of gains and losses over the 6 price changes. Show the gains/losses table. (6)
(c) State the standard overbought and oversold thresholds and explain what a bearish RSI divergence looks like. (3)
Question 3 — MACD code-from-memory (10 marks)
(a) From memory, write the three MACD component formulas (MACD line, signal line, histogram) using standard 12/26/9 parameters. (4)
(b) Write pseudocode for computing the MACD line and histogram given a price array and an ema(arr, n) helper. (4)
(c) Explain what a MACD histogram crossing from negative to positive tells a trader. (2)
Question 4 — Bollinger Bands & ATR (10 marks)
(a) Derive the upper and lower Bollinger Band formulas for a 20-period band at 2 standard deviations. (3)
(b) For prices [20, 22, 24, 22, 22] (treat as the full window, use population std), compute the middle band, standard deviation, and upper/lower bands at 2σ. (5)
(c) Define a "Bollinger squeeze" and state one indicator commonly paired to confirm the breakout direction. (2)
Question 5 — VWAP & Stochastic (10 marks)
(a) Write the VWAP formula and compute VWAP for these intraday bars (use typical price = (H+L+C)/3):
| Bar | High | Low | Close | Volume |
|---|---|---|---|---|
| 1 | 11 | 9 | 10 | 100 |
| 2 | 13 | 11 | 12 | 300 |
| 3 | 15 | 13 | 14 | 100 |
Show the cumulative TP×Vol and cumulative Vol. (6)
(b) Write the %K formula for the stochastic oscillator and compute %K given: current close = 47, lowest low = 40, highest high = 50 over the lookback. (2)
(c) Explain what %D is relative to %K. (2)
Question 6 — Explain out loud: ADX, OBV & indicator overload (8 marks)
(a) State what ADX measures and the conventional threshold that separates a trending from a non-trending market. (2)
(b) Describe how OBV is updated on an up-day vs a down-day. (3)
(c) Explain the concept of "indicator overload" and give one practical rule to avoid it. (3)
Answer keyMark scheme & solutions
Question 1 (10)
(a) Multiplier: . (1) Recursion: . (2)
(b) For : . (1)
- (seed)
- (1)
- (1)
- (1)
- (1)
(c) EMA weights recent prices more heavily via the multiplier , while SMA weights all values equally; older data never fully drops out but decays exponentially, so new prices shift the EMA immediately. (2)
Question 2 (12)
(a) ; . (3)
(b) Price changes (6): +0.5, −0.3, +0.8, +1.0, −0.5, +1.0 (2)
- Gains: 0.5, 0.8, 1.0, 1.0 → sum = 3.3; Avg Gain = 3.3/6 = 0.55 (1)
- Losses: 0.3, 0.5 → sum = 0.8; Avg Loss = 0.8/6 = 0.1333 (1)
- (1)
- (1)
(c) Overbought , oversold . (1) Bearish divergence: price makes a higher high while RSI makes a lower high, signalling weakening momentum and possible reversal down. (2)
Question 3 (10)
(a)
- MACD line (2)
- Signal line (1)
- Histogram (1)
(b) (4)
macd_line = ema(prices,12) - ema(prices,26) # element-wise
signal = ema(macd_line, 9)
histogram = macd_line - signal
(1 mark macd line, 1 signal, 1 histogram, 1 correct alignment/element-wise.)
(c) Histogram crossing from negative to positive means the MACD line has crossed above the signal line — a bullish momentum shift / buy signal. (2)
Question 4 (10)
(a) Middle ; Upper ; Lower . (3)
(b) Mean (1) Deviations: −2,0,2,0,0 → squares 4,0,4,0,0 → sum 8; variance ; (2)
- Upper (1)
- Lower (1)
(c) A squeeze is when the bands contract (low volatility, narrow band width), often preceding a breakout. (1) Pair with ADX (or MACD/volume/OBV) to confirm breakout direction. (1)
Question 5 (10)
(a) . (1) Typical prices: Bar1 ; Bar2 ; Bar3 . (2)
- TP×Vol: ; ; ; sum (1)
- Cumulative Vol (1)
- (1)
(b) (2)
(c) %D is the smoothing (typically 3-period SMA) of %K — it acts as the signal line. (2)
Question 6 (8)
(a) ADX measures trend strength (not direction); ADX > 25 conventionally indicates a trending market, below ~20 indicates non-trending/weak. (2)
(b) Up-day (close > prev close): OBV += volume. Down-day (close < prev close): OBV −= volume. Unchanged: OBV stays the same. (3)
(c) Indicator overload = stacking many correlated indicators that give redundant/conflicting signals, causing analysis paralysis and false confidence. (2) Rule: use a small set from different categories (e.g., one trend, one momentum, one volume). (1)
[
{"claim":"EMA5 for 3-period EMA equals 13.0625","code":"k=Rational(1,2)\ne=10\nfor p in [11,12,13,14]:\n e=p*k+e*(1-k)\nresult=(e==Rational(209,16)) and (float(e)==13.0625)"},
{"claim":"RSI over 6 changes equals ~80.49","code":"ag=Rational(33,10)/6\nal=Rational(8,10)/6\nrs=ag/al\nrsi=100-100/(1+rs)\nresult=abs(float(rsi)-80.4878)<0.01"},
{"claim":"Bollinger upper/lower bands at 2 sigma","code":"import sympy as sp\nvals=[20,22,24,22,22]\nm=sp.Rational(sum(vals),5)\nvar=sp.Rational(sum((v-m)**2 for v in vals),5)\nsd=sp.sqrt(var)\nup=float(m+2*sd)\nlo=float(m-2*sd)\nresult=abs(up-24.5298)<0.01 and abs(lo-19.4702)<0.01"},
{"claim":"VWAP equals 12.0","code":"num=10*100+12*300+14*100\nden=100+300+100\nresult=Rational(num,den)==12"},
{"claim":"Stochastic %K equals 70","code":"k=(47-40)/(50-40)*100\nresult=k==70"}
]