MengNotes
BlogTagsAbout
Home/Blog/66-Day Quant Training, Days 11–17: RSI Divergence, Candlesticks, Volume, and VWAP
Quant-Trading

66-Day Quant Training, Days 11–17: RSI Divergence, Candlesticks, Volume, and VWAP

Days 11–17 of a 66-day quant training program: RSI divergence, Hammer and Bullish Engulfing detection, volume and VWAP, exit-rule comparison, parameter sensitivity, and risk limits.

March 12, 20262,841 words15 min read
#quant-trading#technical-indicators#backtesting#66-days-training#week-summary
Summary

Days 11–17 moved from RSI divergence to candlestick patterns, volume, and VWAP. Every strategy went through a nine-phase backtest. The clearest result was that exit rules can affect performance more than entry signals, while every added filter also reduces signal frequency.


The Seven-Day Learning Map

DayCore TopicIndicator / ToolKey Insight
Day 11RSI Bullish DivergenceRSI DivergencePrice-momentum disagreement signals reversal
Day 12RSI Bearish DivergenceRSI Divergence (Bearish)Short-side logic to capture bull exhaustion
Day 13Hammer + RSIHammer + RSIQuantitative candlestick detection, triple-condition entry
Day 14Bullish Engulfing + SMA FilterBullish Engulfing + SMA(50)Pattern + trend filter reduces false signals
Day 15Volume Spike ReversalVolume Spike + Reversal CandleVolume is the real driver behind every breakout
Day 16VWAP Pullback StrategyVWAP + SMATrading alongside institutions' "fair value"
Day 17Quant Trading Mindset—Risk management, parameter simplicity, second-order derivatives

Day-by-Day Notes

Days 11–12: Turning RSI Divergence into Detectable Conditions

RSI (Relative Strength Index), introduced by J. Welles Wilder in 1978, measures the relative strength of recent gains versus losses.

RSI=100−1001+RSRSI = 100 - \frac{100}{1 + RS}RSI=100−1+RS100​

Where RS=Average GainAverage LossRS = \frac{\text{Average Gain}}{\text{Average Loss}}RS=Average LossAverage Gain​ (typically calculated over 14 periods).

RSI is commonly used for overbought (>70) and oversold (<30) readings. These two days tested divergence: price and RSI move in different directions.

Core Concept

When price makes a new high and RSI does not, price and recent momentum are separating. That is a possible reversal condition, not proof that a reversal is inevitable.

The Four Types of Divergence

Divergence TypePrice ActionRSI ActionSignalTrend Nature
Classic BullishLower Low (LL)Higher Low (HL)BuyReversal
Classic BearishHigher High (HH)Lower High (LH)SellReversal
Hidden BullishHigher Low (HL)Lower Low (LL)BuyContinuation
Hidden BearishLower High (LH)Higher High (HH)SellContinuation
The Golden Rule: Highs for Bearish, Lows for Bullish

For bullish signals, only compare lows (both price and RSI). For bearish signals, only compare highs. Mixing these up is the most common divergence analysis mistake.

Day 11: Bullish Divergence in Practice

The strategy logic: use scipy.signal.argrelextrema to identify swing lows. When price prints a Lower Low but RSI prints a Higher Low, a bullish divergence signal fires, and we enter at the next bar's open.

The core experiment was comparing three exit rules:

  1. RSI Overbought Take-Profit: Exit when RSI ≥ 70
  2. Fixed Percentage Stop-Loss: Exit when close drops below entry × (1 − 5%)
  3. Time Stop: Forced exit after 20 trading days

The same entry signal produced very different risk-return profiles under the three exit rules. That comparison became the main thread for the rest of the week.

Day 12: Bearish Divergence — Catching Bull Exhaustion

Day 12 flipped the perspective: detecting bearish divergence (price making higher highs while RSI prints lower highs) and entering with short-side logic.

The key technical difference was swing high detection using argrelextrema(order=5), with constraints on the distance between the two highs to filter out too-close false signals and too-distant stale signals.

Real-World Divergence Trading

RSI divergence is a condition, not a guarantee. Divergence signals often show a 40–50% win rate; whether the strategy reaches positive expectancy still depends on average gains, average losses, and the exit mechanism.

The consensus from both academic research and the trading community: RSI divergence is most reliable on daily timeframes and above. On 5-minute or 1-minute charts, the false positive rate rises significantly.


Day 13: Defining a Hammer with Math

Candlestick analysis can be traced to 18th-century Japanese rice markets, but “eyeballing” a Hammer does not work in a programmatic backtest. The shape needs explicit conditions.

Quantitative Hammer Conditions

For a bar to qualify as a Hammer, it must satisfy all of the following:

body = abs(close - open)
lower_shadow = min(open, close) - low
upper_shadow = high - max(open, close)

Condition 1: lower_shadow >= body × 2    (lower shadow at least 2× the body)
Condition 2: upper_shadow <= body × 0.3  (minimal upper shadow)
Condition 3: body > 0                     (exclude doji candles)
What the Pattern Really Means

During a decline, price trades sharply lower within the bar and closes back near the open, leaving a long lower shadow. That is the price path encoded by a Hammer.

But entering on a single candle pattern alone is too risky. Day 13's strategy added two layers of confirmation:

  1. RSI Oversold Confirmation: RSI ≤ 40 (a relaxed threshold balancing signal frequency with quality)
  2. Downtrend Confirmation: Close < SMA(20), ensuring the reversal signal appears within an actual downtrend

All three conditions must fire together. That reduces signal count in exchange for stricter confirmation.

Candlestick Pattern Reliability

According to Thomas Bulkowski's classic Encyclopedia of Candlestick Charts and recent quantitative backtest studies, single candlestick patterns have modest reliability (roughly 50–60%). However, when combined with volume confirmation, trend filters, or momentum indicators, accuracy improves significantly. This is exactly why we insist on multi-condition entries.


Day 14: Quantifying Bullish Engulfing

A Bullish Engulfing pattern consists of two bars: the second bullish body fully covers the first bearish body.

Quantitative Detection Conditions

Condition 1: prev_close < prev_open         (prior bar is bearish)
Condition 2: curr_close > curr_open          (current bar is bullish)
Condition 3: curr_open <= prev_close         (current open ≤ prior close)
Condition 4: curr_close >= prev_open         (current close ≥ prior open)
Condition 5: body > 0                        (exclude doji candles)

Visually, the second candle "swallows" the first entirely, representing buyers overpowering sellers within a single session. In backtest research, the Bullish Engulfing near support levels with high volume confirmation ranks among the most reliable candlestick patterns.

The SMA(50) Trend Filter

Day 14 introduced SMA(50) as a trend filter: long signals are only allowed when close > SMA(50). The underlying logic:

We only want to catch short-term pullback rebounds within a medium-term uptrend, not "catch falling knives" in a downtrend.

Parameter optimization tested 36 combinations (SMA period × stop-loss percentage × holding days), which led us to a crucial lesson:

The Power of Holding Period

In many strategies, the holding period has a far greater impact on performance than you'd expect. Day 14's backtests showed that 3-day vs. 20-day holding periods could produce Sharpe Ratio differences of 2× or more. Exit timing often matters more than entry conditions.


Day 15: Adding Volume to the Reversal Conditions

From Day 4 through Day 14, every entry condition came from price: SMA, RSI, or candlestick patterns. Day 15 added volume for the first time.

Quote

Price tells you what the market is doing. Volume tells you how serious the market is about it.

Defining a Volume Spike

The quantitative definition is straightforward:

Volume Spike:Volumetoday>SMA20(Volume)×k\text{Volume Spike}:Volume_{today} > SMA_{20}(Volume) \times kVolume Spike:Volumetoday​>SMA20​(Volume)×k

Where kkk is the spike multiplier (default k=2k = 2k=2, meaning today's volume exceeds the 20-day average by at least 2×).

This signals an abnormally high level of trading activity — potentially institutional accumulation, panic selling, or a collective reaction to major news.

Triple Entry Conditions

Day 15's strategy required all three conditions simultaneously:

  1. Volume Spike: Volume > 20-day average volume × 2
  2. Reversal Candlestick: Hammer or Bullish Engulfing (integrating the detection logic from Days 13 and 14)
  3. Trend Filter: Close > SMA(50)

This was the first strategy to combine the prior days' pattern detection, trend filter, and a volume condition.

Parameter Optimization Observations

Testing 48 parameter combinations (spike multiplier × SMA period × holding days):

  • Spike multiplier had the largest impact on strategy quality. Too low (1.5×) included too many "non-event" days; too high (3.0×) generated almost no signals
  • In this test, the more robust zone was 2.0–2.5×. That is a result for the tested tickers and period, not a universal threshold
Volume Context

A volume spike shows that participation has changed, but volume alone cannot identify who traded. It does not prove that institutions, hedge funds, or market makers entered or exited. Price structure and trend still need separate confirmation.


Day 16: Using VWAP as an Intraday Execution Benchmark

VWAP (Volume Weighted Average Price) weights intraday prices by volume and is widely used as an execution benchmark.

The Formula

TP=High+Low+Close3TP = \frac{High + Low + Close}{3}TP=3High+Low+Close​ VWAP=∑(TP×Volume)∑VolumeVWAP = \frac{\sum(TP \times Volume)}{\sum Volume}VWAP=∑Volume∑(TP×Volume)​

A critical property: VWAP resets automatically at the start of each trading day, accumulating from zero. Early in the session the denominator is small, making VWAP highly sensitive to price changes; as the day progresses, the growing cumulative volume makes it increasingly stable.

VWAP's Market Significance

VWAP is commonly used to evaluate intraday execution quality. An average buy price below VWAP is below that day's volume-weighted average. Whether VWAP behaves as support or resistance still has to be tested in the actual intraday data.

The VWAP Pullback Strategy

The idea: in an uptrend (close > SMA(20)), when price pulls back from above VWAP to VWAP, treat it as a buying opportunity.

Entry Conditions:

  • Previous bar close > VWAP, current bar close ≤ VWAP (pullback detected)
  • Close > SMA(20) (trend filter)
  • Exclude the first 30 minutes after open (09:30–10:00, excessive volatility)

Exit Rule Comparison (three approaches):

  • Exit A: Hold for a fixed number of bars (e.g., 12 bars × 5 min = 1 hour)
  • Exit B: Fixed percentage take-profit (+2%)
  • Exit C: Exit when SMA(20) is breached

Backtest Performance and Key Findings

TickerParametersIS SharpeOOS SharpeKey Observation
AAPLSMA=50, Hold=36-3.810.39Drawdown control superior to Buy-and-Hold
SPYSMA=10, Hold=362.441.30Achieved excess returns; IS→OOS decay but remained positive
VWAP Limitations

In extremely strong uptrends, price can stay above VWAP for multiple consecutive days without a single pullback. If you insist on waiting to "buy below VWAP," you'll completely miss the rally. VWAP is an intraday tool — it should not be used for cross-day trend analysis.

The professional approach: pair VWAP with higher-timeframe trend analysis. VWAP tells you "where today's fair value is," but the trend direction needs daily or weekly indicators to determine.


Day 17: Pausing the Code to Revisit Risk and Parameters

Day 17 had no coding. We read QFX Research's “1 Year in Quant Trading — 24 Lessons I've Learned” and selected three lessons that connected directly to the first 16 days.

Lesson #9: Make Risk Management Your Top Priority

Your strategy should be able to handle waking up one morning to find the market has crashed 50%.

Losing 40% of your capital requires a 66.7% gain just to break even — the math is fundamentally asymmetric. Over the first 16 days of training, we'd generated impressive backtest numbers but never seriously asked: if the worst-case scenario hit, would the account survive?

A Risk Management Framework:

LevelPrincipleQuantitative Standard
Per TradeMaximum risk per trade≤ 1% of total capital
DailyMaximum daily loss≤ 3% of total capital
StrategyMaximum drawdown tolerance≤ 20%, pause if exceeded
AccountReserve fund isolation20% of capital never deployed

The primary goal isn't "to make money" — it's "to not go bankrupt." Survival comes first; compounding follows.

Lesson #10: Use Fewer Parameters, but Understand Them Deeply

My best-performing strategy had only 3 parameters. The worst mistake was probably letting an optimization script auto-generate parameter combinations.

During training, we often ran grid searches across SMA periods, RSI thresholds, and holding durations, finding the "best-looking" combination — without knowing why those parameters worked. This is essentially overfitting to historical data, not discovering genuine market structure.

Before adding any parameter, answer three questions:

  1. What market behavior does this parameter represent? (e.g., SMA 200 = long-term trend direction)
  2. Why should it affect strategy performance? (logic-driven, not data-driven)
  3. Does the strategy collapse if you change this value slightly? (robustness test)

Only when all three answers are clear does a parameter deserve a place in your strategy.

Lesson #20: The Derivative of the Derivative Is Where the Value Lies

If you strategically transform an indicator into a second-order derivative, strategy performance often improves significantly.

Don't rush to learn a new indicator. First ask: what is the second-order behavior of the indicator I already have?

  • RSI → Rate of change of RSI (momentum acceleration) → Consecutive positive slopes (trend confirmation)
  • MACD → Cumulative histogram area → Rate of area sign change
  • VWAP deviation → Standard deviation of deviation (intraday volatility rhythm) → Deviation mean-reversion speed
The Common Thread of All Three Lessons

Understand → Simplify → Survive → Derive

  1. Understand the market meaning of every parameter and indicator
  2. Simplify to the core logic you truly command
  3. Survive — it's the precondition for all compounding
  4. On top of understanding, derive more insightful features

Going deep on one indicator you understand beats spreading thin across ten you don't.


Findings That Recurred Across Seven Days

Exits Matter More Than Entries

The most consistent result this week was that exit rules may affect strategy performance more than entry signals.

Day 11's three exit rule comparisons, Day 14's holding period sensitivity analysis, Day 16's three exit logic comparisons — each validated the same truth: the same entry signal paired with different exit mechanisms can produce Sharpe Ratio differences of 2× or more.

That is why a backtest cannot tune only entry conditions. Stop-losses, take-profits, and holding periods need their own sensitivity analysis.

More Conditions Mean Fewer False Signals and Fewer Trades

From Day 11's pure RSI divergence, to Day 13's triple conditions (pattern + RSI + trend), to Day 15's triple conditions (volume + pattern + trend), the design trajectory is clear:

A meaningful filter can remove some false signals, but it also lowers signal frequency.

This is an eternal trade-off: confirmation vs. trading frequency. There's no right answer — only the answer that fits your capital size and risk tolerance.

From Daily Bars to Minute Bars

Day 16's VWAP strategy took us from daily charts into the 5-minute bar world for the first time. Intraday trading presents entirely different challenges:

  • Data volume explodes (78 five-minute bars per day)
  • Must account for "opening volatility periods" and "end-of-day forced liquidation"
  • VWAP resets daily — indicator logic is fundamentally different from daily indicators
  • Transaction costs consume a larger share (because expected profit per trade is smaller)

Strategy Toolbox Quick Reference

ToolTypeBest Use CaseCore Limitation
RSI DivergenceMomentum ReversalSwing high/low turning point detectionLow win rate, requires exit discipline
HammerCandlestick PatternReversal signal in downtrendsLow reliability when used alone
Bullish EngulfingCandlestick PatternStrong reversal confirmationRequires trend filter
Volume SpikeVolumeLocating abnormal trading activityMultiplier threshold varies by ticker
VWAPIntraday BenchmarkFair value anchor for day tradingIntraday only, resets daily
SMA FilterTrend ConfirmationFiltering counter-trend false signalsLagging by nature

Six Rules from the Week

  1. Exits determine survival. Entry is just the beginning of the story; exit is the ending. Time spent designing exit rules should at least match time spent on entry conditions.
  2. Multiple confirmations are your seatbelt. Single indicators are rarely reliable, but meaningful multi-condition combinations significantly reduce false signals.
  3. Risk management isn't optional — it's foundational. Losing 40% requires gaining 66.7% to recover. That math never changes.
  4. Less is more. Three parameters you understand beat ten parameters you've merely optimized.
  5. Go deep, not wide. Understanding one indicator's second-order behavior is worth more than learning ten new ones.
  6. Volume is confirmation, not identity. A spike deserves investigation, but it cannot identify the participants or guarantee a reversal by itself.

What's Next

Day 18 begins more advanced strategy combinations and portfolio-level questions, using the same out-of-sample checks and risk limits.

Table of Contents

The Seven-Day Learning MapDay-by-Day NotesDays 11–12: Turning RSI Divergence into Detectable ConditionsDay 13: Defining a Hammer with MathDay 14: Quantifying Bullish EngulfingDay 15: Adding Volume to the Reversal ConditionsDay 16: Using VWAP as an Intraday Execution BenchmarkDay 17: Pausing the Code to Revisit Risk and ParametersFindings That Recurred Across Seven DaysExits Matter More Than EntriesMore Conditions Mean Fewer False Signals and Fewer TradesFrom Daily Bars to Minute BarsStrategy Toolbox Quick ReferenceSix Rules from the Week
← Back to all posts

© 2024-2026 MengNotes | All Rights Reserved