Pivot-Confirmed Divergence Detection → TradingView Screener → Strategy Calibration
Cron runs automatically at 6am weekdays. Results appear here on next refresh.
A scanner that detects when smart money is quietly buying or selling before the price moves. It watches volume flow (OBV) and compares it to price action. When they disagree — that's a divergence, and it often predicts the next move.
The core signal. Finds moments where price is making new lows but volume flow (OBV) is actually rising — meaning institutions are buying into the weakness. Or the reverse: price making new highs while OBV drops — institutions selling into strength.
Only triggers when both price AND OBV have confirmed swing points (pivots). This eliminates noise and false signals.
Momentum confirmation. When OBV breaks above its recent high or below its recent low, it confirms the direction of money flow. Think of it as OBV "breaking out" before price does.
Spotting big-player activity. A candle with huge volume but a tiny body means someone moved a lot of money but price barely budged — that's absorption (a wall of buying or selling). A big body + big volume = a sponsored, intentional move.
Speed comparison. Measures how fast OBV is changing vs how fast price is changing. When OBV is moving faster than price (leading), it hints at what's coming next. Green background = OBV leading up. Red = OBV leading down.
Context awareness. Automatically detects when price is stuck in a range (double bottom, wedge, triangle, channel). Divergences inside a range are the highest-conviction setups because the range is about to break.
Labels: DB = Double Bottom, DT = Double Top, T▲ = Ascending Triangle, W▼ = Descending Wedge, SR = Support/Resistance
Setup quality meter. Scores how "ready" a setup is based on 5 factors: Is volume declining? (institutions accumulating quietly) Is the range tightening? Does OBV disagree with price? Is the weekly trend aligned? Are there absorption candles? Higher score = higher conviction.
See the big picture. When you're on a 4-hour chart, the indicator still shows you Daily, Weekly, and Monthly divergences as overlay lines. A divergence on a higher timeframe is a stronger signal than one on a lower timeframe.
| Input | Default | Range | What it does |
|---|---|---|---|
| Pivot Length (D/H4) | 2 | 1-20 | How many bars on each side to confirm a swing point on Daily/H4. Lower = faster but noisier. |
| Pivot Length (W/M) | 5 | 2-20 | Same but for Weekly/Monthly. Higher because weekly data is already smoother. |
| Min Span (D/H4) | 5 | 2-30 | Minimum bars between two pivots for a valid divergence. Filters out tiny, meaningless swings. |
| Min Span (W/M) | 15 | 3-50 | Same for Weekly/Monthly. Wider because weekly divergences develop over months. |
| Max Lookback | 100 | 20-300 | How far back to look for the previous pivot. If two pivots are 100+ bars apart, they're probably unrelated. |
| OBV Break Window | 30 | 10-60 | How many bars to check when looking for an OBV breakout above/below its range. |
| Slope Period | 20 | 5-50 | Window for comparing OBV speed vs price speed. 20 = about 1 month on daily. |
| Slope Diverge % | 15% | 1-50% | How different OBV and price slopes need to be before highlighting. 15% = meaningful gap. |
| Effort Vol x | 2.5 | 1-10 | How much higher than average volume a candle needs to qualify as an "effort" candle. 2.5x = significant. |
| Max Body % | 0.5 | 0.1-0.8 | Max candle body size (vs total range) for absorption detection. 0.5 = body is less than half the range. |
| Range Lookback | 30 | 10-80 | How many bars to analyze when detecting range patterns (wedges, triangles, etc.). |
| ATR Tolerance | 0.5 | 0.2-2.0 | How close a price needs to get to a level to count as "touching" support/resistance. In ATR units. |
| Vol Short | 20 | 5+ | Recent volume average (20 bars). Compared to Vol Long to detect volume decline — a setup precondition. |
| Vol Long | 50 | 10+ | Baseline volume average (50 bars). If Vol Short < Vol Long, volume is declining — institutions may be accumulating. |
| Option | Default | What it shows |
|---|---|---|
| Divergence | ON | The main signal lines connecting pivots. Always keep this on. |
| Ranges | ON | Boxes around detected patterns (DB, DT, wedges). Helpful for context. |
| Table | ON | Stats panel showing score, OBV slope, volume, signals. |
| OBV | ON | The white OBV line in the bottom panel. Always keep on. |
| EMA | OFF | 20-period moving average of OBV. Smooths the line but adds clutter. |
| Breaks | OFF | Triangle markers when OBV breaks its range. Noisy on most charts. |
| Effort | OFF | Dots/arrows for absorption and sponsored candles. Useful for analysis, clutters for scanning. |
v3: Pivot-confirmed divergence, per-TF pivot lengths (D=2, W=5), min span calibration (D=5, W=15), MTF detection, OBV line alignment fix, range pattern shortcodes, StoiQ-inspired hub.
v2: Basic divergence + context filters. No pivot confirmation, no MTF.
| Phase | Period | Signals | WR% | Avg Return |
|---|---|---|---|---|
| Train | Year 1 (51 weeks) | 687 | 51.9% | +0.82% |
| Test | Year 2-3 (104 weeks) | 659 | 58.3% | +1.12% |
| Pivot Len (D) | Pivot Len (W) | Signals | WR% | Avg Ret | PF |
|---|---|---|---|---|---|
| 2 | 5 | 1,346 | 54.5% | +0.98% | 1.54× |
| 2 | 4 | 1,562 | 52.8% | +0.85% | 1.41× |
| 3 | 5 | 952 | 56.2% | +1.15% | 1.68× |
| 2 | 6 | 1,089 | 55.1% | +1.05% | 1.62× |
The strategy file (obv_strategy_v3.pine) replicates the Python backtest in Pine Script:
Quarterly: Run full backtest sweep every 3 months to detect regime drift.
After Major Macro Events: Fed pivot, yield curve inversion, sector rotation.
After 50-Signal Sample: If new data shows WR dropping >3%, investigate.
Pivot Length: Increase if too many false signals; decrease if missing setups.
Lookback: Narrow to 50-80 bars if in choppy regime; expand to 120+ in trending markets.
Context Score Threshold: Raise from 65 to 75 if false signals increase.
obv_system_v3.pineTip: Save as public script so you can use it on any chart without re-pasting.
Once added to chart, click the indicator name → Settings icon → Input tab:
| Input | Recommended Value |
|---|---|
| Pivot Length (D/H4) | 2 |
| Pivot Length (W/M) | 5 |
| Max Lookback | 100 |
| Divergence (Display) | ON |
| Ranges (Display) | ON |
| Table (Display) | ON |
| OBV (Display) | ON |
| EMA (Display) | OFF |
| Breaks (Display) | OFF |
| Effort (Display) | OFF |
python3 src/screener/scan_lite.pysrc/screener/output/tradingview_watchlist.txtTip: Set watchlist to sort by % change to spot momentum movers.
Tip: Use browser notifications for quick response; set daily 9:30-16:00 ET to avoid noise.
Morning (9:30 AM ET):
python3 src/screener/scan_lite.py --preset unusual_volDuring Market Hours:
End of Day (4:00 PM ET):
| Issue | Solution |
|---|---|
| No divergence lines show | Check: Display → Divergence = ON. Ensure chart has enough history (>100 bars). |
| Too many false signals | Increase Pivot Length to 3. Raise Context Score filter to 75. Use MTF confirmation. |
| Indicator is very slow | Disable MTF requests if on low-TF charts. Disable Effort candles (Layer 3). |
| Finviz screener fails (401) | Check .env: FINVIZ_API_TOKEN correct? Not expired? Try manual export from elite.finviz.com. |