Advanced Topics in Algorithmic Trading: Part 1

Advanced Topics in Algorithmic Trading: Part 1, Using Technical Indicators to time entrances and exits in algorithmic trading.
Course Description
This course explores popular technical indicators used in quantitative trading, focusing on moving averages, MACD, Z-score, and RSI. These indicators help identify trends, detect overbought or oversold conditions, and refine trading strategies.
1. Moving Averages
A Simple Moving Average (SMA) is calculated by averaging prices over a set period. The look-back window length affects the responsiveness of the SMA:
• Longer look-back windows create smoother trends but introduce lag.
• Shorter look-back windows follow price movements more closely but generate more noise.
An alternative is the Exponential Moving Average (EMA), which applies greater weight to recent prices:
• The decay factor (λ) determines how much past data influences the EMA.
• Higher λ values create smoother EMAs but introduce lag.
• Lower λ values make the EMA track prices more closely but increase volatility.
2. MACD (Moving Average Convergence Divergence)
The MACD indicator measures the relationship between two EMAs:
• Fast EMA – Slow EMA = MACD Series.
• When the fast EMA crosses above the slow EMA, it indicates an uptrend.
• When the fast EMA crosses below, it signals a downtrend.
A third EMA, called the MACD Signal, smooths the MACD Series:
• MACD Divergence (MACD – MACD Signal) helps identify buy and sell opportunities.
• Reducing λ values makes the indicator react faster but increases false signals.
3. Price Z-Score
The Z-score quantifies how far the current price deviates from its historical average, helping to determine rich (overpriced) or cheap (underpriced) conditions:
• Z = (Current Price – EMA Price) / Volatility
• A high Z-score indicates overvaluation; a low Z-score suggests undervaluation.
• Increasing λ creates smoother, less volatile Z-scores.
• Lower λ allows the Z-score to track prices more closely but increases false signals.
4. Relative Strength Index (RSI)
The RSI measures price momentum and indicates overbought or oversold conditions:
• RSI = 100 – [100 / (1 + Average Gain / Average Loss)]
• RSI above 70 suggests overbought conditions (sell signal).
• RSI below 30 suggests oversold conditions (buy signal).
By adjusting λ, traders can fine-tune the RSI:
• Higher λ smooths RSI movements but delays signals.
• Lower λ makes RSI more sensitive to price changes but increases noise.
5. Trading Strategy Simulation
A basic RSI-based strategy is tested:
• Buy when RSI falls below a threshold (θ).
• Sell when RSI exceeds 1 – θ.
• The strategy maintains a long or short position based on RSI trends.
The Sharpe ratio comparison shows that:
• SPY ETF has a Sharpe ratio of 0.6.
• The RSI strategy achieved 0.8, suggesting better risk-adjusted returns.
• However, the strategy underperformed post-2017, indicating potential overfitting.
Conclusion
Technical indicators like SMA, EMA, MACD, Z-score, and RSI are valuable tools but require careful parameter tuning. They can improve trade timing, but overfitting risks mean strategies must be tested on new data to ensure effectiveness.