$npx -y skills add SKE-Labs/agent-trading-skills --skill macd-tradingDefine and test MACD line, signal, histogram, zero-line, and divergence features. Use when evaluating closed-bar momentum/trend rules with explicit parameters, exits, regime context, and costs.
| 1 | # MACD Trading Strategy |
| 2 | |
| 3 | MACD (Moving Average Convergence Divergence) combines trend-following and momentum analysis. |
| 4 | |
| 5 | ## Components |
| 6 | |
| 7 | | Component | Calculation | Use | |
| 8 | | --------------- | --------------- | ------------------ | |
| 9 | | **MACD Line** | 12 EMA - 26 EMA | Trend direction | |
| 10 | | **Signal Line** | 9 EMA of MACD | Entry trigger | |
| 11 | | **Histogram** | MACD - Signal | Momentum strength | |
| 12 | | **Zero Line** | Centerline | Bull/bear boundary | |
| 13 | |
| 14 | ## Signals |
| 15 | |
| 16 | ### Crossover |
| 17 | |
| 18 | - **Bullish**: MACD crosses above Signal line → buy |
| 19 | - **Bearish**: MACD crosses below Signal line → sell |
| 20 | - Record whether a cross occurs above or below zero as context; do not assign strength without validation |
| 21 | |
| 22 | ### Zero Line Cross |
| 23 | |
| 24 | - MACD above zero = bullish trend |
| 25 | - MACD below zero = bearish trend |
| 26 | - Cross of zero = trend change confirmation |
| 27 | |
| 28 | ### Histogram |
| 29 | |
| 30 | - Growing histogram = increasing momentum |
| 31 | - Shrinking histogram = weakening momentum (often precedes crossover) |
| 32 | |
| 33 | ### Divergence |
| 34 | |
| 35 | - Price new high + MACD lower high → bearish divergence |
| 36 | - Price new low + MACD higher low → bullish divergence |
| 37 | |
| 38 | ## Workflow |
| 39 | |
| 40 | 1. **Get MACD**: |
| 41 | ``` |
| 42 | get_indicators(indicator_code="macd", symbol=<symbol>, exchange=<exchange>, interval=<interval>) |
| 43 | ``` |
| 44 | |
| 45 | 2. **Record zero-line state** as one feature; it does not determine direction by itself |
| 46 | |
| 47 | 3. **Wait for crossover** in trend direction. Confirm with histogram growing in direction. |
| 48 | |
| 49 | 4. **Check for divergence** between price and MACD line/histogram |
| 50 | |
| 51 | 5. **Get candles for context**: |
| 52 | ``` |
| 53 | get_candles_around_date(symbol=<symbol>, exchange=<exchange>, interval=<interval>, date=<date>) |
| 54 | ``` |
| 55 | |
| 56 | 6. **Exit**: choose one objective crossover, histogram, price, target, or time rule before entry and test it separately |
| 57 | |
| 58 | ## Evidence and Validation |
| 59 | |
| 60 | - Treat the setup as a testable hypothesis, not a prediction. Define thresholds, entry, invalidation, and exit before evaluating outcomes. |
| 61 | - Calibrate on the same instrument, venue, session, and timeframe. Use closed candles and a held-out or walk-forward sample; record every variant tried. |
| 62 | - 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. |
| 63 | - Return observed inputs, missing data, cost assumptions, entry, invalidation, exit, and a valid, watch, or no-trade status. |
| 64 | - Research basis: Cross-market studies summarized in the [technical-rule evidence](https://pmc.ncbi.nlm.nih.gov/articles/PMC4583561/) show MACD performance varies by market and costs; a crossover is a feature, not an edge by itself. |
| 65 | |
| 66 | ## Key Rules |
| 67 | |
| 68 | - A crossover is a lagged price-derived feature; require a separately validated decision rule. |
| 69 | - Test zero-line and higher-timeframe filters for incremental held-out value. |
| 70 | - Treat 12/26/9 as the conventional baseline and record all parameter variants tried. |
| 71 | - Define histogram expansion/shrinkage over a fixed number of closed bars. |
| 72 | - Do not label a crossover confirmation unless its conditional outcome distribution supports that use. |
| 73 | |
| 74 | ## Related Skills |
| 75 | |
| 76 | - **divergence-trading** — multi-indicator divergence framework that includes MACD |
| 77 | - **moving-average-crossover** — MACD is derived from EMAs; combine for confirmation |