Fibonacci ATH - Swing Low Rules
This rulebook only fixes two anchors: the swing high (the all-time high) and the accepted swing low. It contains no entry, exit or position rule. Strategies are built on top of it only after the swings have been checked by hand.
Code: backend/silverarb/fib_swings.py. Run from backend/:
python -m silverarb.fib_swings # asks instrument, then date
python -m silverarb.fib_swings --inst 3 --date 2020-12-11 # one shot
python -m silverarb.fib_swings --inst 1 --date 2008-03-31 --mult 15 --cycles 20
Instruments: 1 NIFTY, 2 BANKNIFTY (index spot, NSE EOD), 3 SilverM, 4 GoldM (MCX continuous nearest-month futures, series I).
1. Data
- Daily OHLC with one price unit. Index spot for NIFTY / BANKNIFTY; continuous futures
SILVERM-I/GOLDM-Ifor the MCX metals (the MCX spot series has closes only, so it cannot give true highs and lows). - Breakdowns and breakouts are confirmed by daily closes only. No later candle is read: the report for a date uses only bars up to that date.
- Early history can be close-only (NIFTY before about 1996, BANKNIFTY before 2005: high = low = close). Anchors that fall in those years are weaker.
2. Anchors
- Swing high = the all-time high (ATH) of the series.
- Swing low = the accepted low, set by the breakdown-breakout cycle, the size filter and the death-zone rule below.
3. Cycle
- Fib level.
Level_23.6 = ATH - 0.236 * (ATH - accepted swing low). - Breakdown. A daily close strictly below
Level_23.6. At that moment freeze the reference ATH and the Fibonacci levels, and recordATR50_breakdown= ATR(50) using data up to that day's close. It is never recalculated during the cycle. - Candidate swing low. From the breakdown candle through the breakout candle (inclusive), the lowest daily low.
- Breakout. A daily close strictly above the frozen ATH. The new ATH is the highest daily high recorded through the breakout candle.
- Size filter.
Swing_Size = Frozen_ATH - Candidate_Low,Minimum_Size = 20 * ATR50_breakdown. IfSwing_Size >= Minimum_Sizethe candidate becomes the accepted swing low; otherwise the previous accepted low is kept. - Next cycle starts from the updated ATH and the accepted swing low.
4. Death zone (additional rule)
- Trigger: inside a cycle, a daily close strictly below the 61.8% level
Level_61.8 = Frozen_ATH - 0.618 * (Frozen_ATH - previous accepted swing low). - Effect: every previous swing low is erased. The swing low is now the lowest daily low since the ATH day (it keeps moving down while the cycle is open and is shown live in the report).
- At the breakout of that cycle the lowest low since the ATH day is accepted as the swing low without the size filter, because no earlier low is left to keep. This is a decision I made; change it if you want the filter applied here too.
Worked example (verified by hand): NIFTY, ATH 1,818.15 on 2000-03-13, death zone on 2000-10-17 -> every pre-2000 low is dropped and the swing low becomes 849.95 (2001-09-21). Report for 2008-03-31: swing high 6,357.10 (2008-01-08), swing low 849.95.
5. Choices the rulebook leaves open
| Choice | Used |
|---|---|
| ATR(50) | Wilder smoothing of True Range, seeded with the simple mean of the first 50 TRs; no breakdown before bar 50 |
| Start-up anchors (before the first breakdown) | ATH = running highest high; swing low = lowest low from the series start up to the ATH day, re-derived while the ATH keeps rising |
| Outside a cycle | A higher high raises the ATH; the accepted swing low is unchanged |
| Bars with missing / inconsistent high or low | Repaired from the close and counted in the report |
6. What each run records
Breakdown date, frozen ATH, frozen ATR(50), candidate swing low (and its date), swing size, minimum size, qualification result, death-zone date (if any), accepted swing low, breakout date, updated ATH. An open cycle shows its state as of the chosen date.
7. Research runs
The primary threshold is 20 x ATR(50). Test the alternatives in separate runs (--mult 10 / 15 / 25 / 30; --atr changes
the ATR length) and record each as a variant of the strategy in the Strategy Catalogue.
8. Checked so far
| Instrument | As of | Swing high | Swing low | Status |
|---|---|---|---|---|
| NIFTY | 2008-03-31 | 6,357.10 | 849.95 | confirmed by hand |
| SilverM-I | 2020-12-11 | 77,833 | 33,051 (2015-12-17) | high confirmed; low kept as the rule gives it (you expected 33,300) |
| BANKNIFTY, GoldM-I | - | - | - | not yet checked |