Risk filter
Marks bars where ADX is 35 or lower, a safe-to-trade gate that blocks strong trends rather than signalling entries.
RiskFilter returns True on a bar unless the 14-bar ADX is above 35, which means a strong trend in either direction. It also has an ATR check that would return False when ATR exceeds 10% of price, but on SPY ATR stays near 0.02% of price, so that check never fires. Its lookback_period setting is accepted and never used.
How to read it
- Markers sit on bars that count as safe, in long runs; at defaults they cover about 83% of candles, so the gaps matter more than the marks.
- A gap in the markers is a stretch where ADX is above 35, and entries would be blocked there.
- A run of markers starts again when ADX falls back to 35 or below, about 7.5 times a day in the September 2026 SPY sample.
What it outputs
- Safe to trade
- Drawn on bars where ADX is 35 or lower, so the trend is not strong enough to block trades. Bars with ADX above 35 get no marker.
When it fires
Fires on each bar where ADX is 35 or lower, which is 83% of bars at defaults. The useful moment is a run starting: ADX has dropped back to 35 or below after a strong trend, lifting the block on entries.
Settings
- lookback_period
- Has no effect. The code accepts it but never reads it, so raising or lowering it leaves the chart unchanged. The ADX and ATR it reads always use their own default 14-bar windows.
Pitfalls
- The ATR check never fires on SPY. It would block when ATR exceeds 10% of price, but ATR peaked near 0.1% of price in the sample, so only ADX gates trades.
- lookback_period is never read, so the preset above and any other value show the same chart.
- ADX ignores direction, so a strong rally and a strong sell-off both block. At defaults about 17% of bars are blocked, so most bars are marked as safe.