$npx -y skills add SKE-Labs/agent-trading-skills --skill divergence-tradingDefine and test regular or hidden divergence at objective pivots. Use when aligning RSI, MACD, Stochastic, MFI, or volume features to exact price-pivot timestamps without counting correlated indicators as independent votes.
| 1 | # Divergence Trading |
| 2 | |
| 3 | Divergence occurs when price and an indicator move in opposite directions, signaling potential trend change or continuation. |
| 4 | |
| 5 | ## Divergence Types |
| 6 | |
| 7 | ### Regular Divergence (Reversal) |
| 8 | |
| 9 | | Type | Price | Indicator | Signal | |
| 10 | | --- | --- | --- | --- | |
| 11 | | **Bullish Regular** | Lower Low | Higher Low | Momentum weakening, potential reversal up | |
| 12 | | **Bearish Regular** | Higher High | Lower High | Momentum weakening, potential reversal down | |
| 13 | |
| 14 | ### Hidden Divergence (Continuation) |
| 15 | |
| 16 | | Type | Price | Indicator | Signal | |
| 17 | | --- | --- | --- | --- | |
| 18 | | **Bullish Hidden** | Higher Low | Lower Low | Uptrend pullback ending, continuation up | |
| 19 | | **Bearish Hidden** | Lower High | Higher High | Downtrend rally ending, continuation down | |
| 20 | |
| 21 | ## Multi-Indicator Detection |
| 22 | |
| 23 | | Indicator | Best For | Extreme Zone | |
| 24 | | --- | --- | --- | |
| 25 | | RSI | OB/OS exhaustion | <30 or >70 for regular div | |
| 26 | | MACD histogram | Momentum shifts | Compare histogram peaks/troughs with price | |
| 27 | | Stochastic | Ranging markets | <20 or >80 (skip mid-range div) | |
| 28 | | MFI (price/volume transform) | Volume-aware momentum | Define pivots and compare slopes | |
| 29 | |
| 30 | RSI, MACD, and Stochastic are correlated transforms of price, while MFI also uses volume. Do not count them as independent votes or map the count to probability; compare each feature and any combination with a price-only baseline. |
| 31 | |
| 32 | ## Validation Rules |
| 33 | |
| 34 | - Use an objective pivot algorithm with fixed left/right bars or ATR reversal and exclude the unconfirmed right-edge pivot. |
| 35 | - Calibrate minimum/maximum spacing and optional oscillator zones by instrument/timeframe. |
| 36 | - Match indicator values at the exact price-pivot timestamps; use closed data and specify equality tolerance. |
| 37 | |
| 38 | ## Workflow |
| 39 | |
| 40 | 1. **Get indicator data**: |
| 41 | ``` |
| 42 | get_indicators(indicator_code="rsi", symbol=<symbol>, exchange=<exchange>, interval=<interval>) |
| 43 | get_indicators(indicator_code="macd", symbol=<symbol>, exchange=<exchange>, interval=<interval>) |
| 44 | get_indicators(indicator_code="stoch", symbol=<symbol>, exchange=<exchange>, interval=<interval>) |
| 45 | ``` |
| 46 | |
| 47 | 2. **Compare swings**: For each indicator, identify last two significant peaks/troughs and compare direction vs price direction |
| 48 | |
| 49 | 3. **Evaluate**: report each divergence and contextual feature separately; use a numeric score only if calibrated on held-out labels. |
| 50 | |
| 51 | 4. **Get candles for chart drawing**: |
| 52 | ``` |
| 53 | get_candles_around_date(symbol=<symbol>, exchange=<exchange>, interval=<interval>, date=<date>) |
| 54 | ``` |
| 55 | |
| 56 | 5. **Mark divergence on chart**: |
| 57 | ``` |
| 58 | draw_chart_analysis(action="create", drawing={ |
| 59 | "type": "trend", |
| 60 | "points": [ |
| 61 | {"time": <first_low_time>, "price": <first_low_price>}, |
| 62 | {"time": <second_low_time>, "price": <second_low_price>} |
| 63 | ], |
| 64 | "options": {"text": "Bullish Divergence (RSI + MACD)"} |
| 65 | }) |
| 66 | ``` |
| 67 | |
| 68 | 6. **Wait for confirmation candle** (engulfing, hammer, pin bar) at the divergence zone before entry |
| 69 | |
| 70 | ## Evidence and Validation |
| 71 | |
| 72 | - Treat the setup as a testable hypothesis, not a prediction. Define thresholds, entry, invalidation, and exit before evaluating outcomes. |
| 73 | - Calibrate on the same instrument, venue, session, and timeframe. Use closed candles and a held-out or walk-forward sample; record every variant tried. |
| 74 | - Include spread, fees, slippage, borrow or funding, partial fills, and latency. Reject the setup when net expectancy is not positive or depends on one narrow parameter. |
| 75 | - Return observed inputs, missing data, cost assumptions, entry, invalidation, exit, and a valid, watch, or no-trade status. |
| 76 | - Research basis: The [technical-analysis evidence review](https://papers.ssrn.com/sol3/Delivery.cfm/SSRN_ID603481_code17745.pdf?abstractid=603481) finds mixed performance and common data-snooping problems; multiple correlated oscillators do not create independent confirmation. |
| 77 | |
| 78 | ## Key Rules |
| 79 | |
| 80 | - Do not treat multiple price-derived oscillators as independent confirmation. |
| 81 | - Calibrate oscillator zones rather than declaring mid-range values meaningless. |
| 82 | - Define an objective closed-bar entry and invalidate beyond the second pivot plus buffer. |
| 83 | - Test timeframe and regime interactions; no timeframe is universally more reliable. |
| 84 | - Keep unresolved divergences and failures in the evaluation sample. |
| 85 | - Entry on confirmation candle close; stop beyond the second divergence swing point |
| 86 | |
| 87 | ## Related Skills |
| 88 | |
| 89 | - **rsi-divergence** — focused RSI divergence framework; this skill extends it to multiple indicators |
| 90 | - **macd-trading** — MACD histogram divergence is one of the four indicators in multi-indicator scoring |