diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 04c95db..16e4d26 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -50,6 +50,13 @@ - Safety bounds: MIN/MAX caps prevent extremes - Falls back to fixed % if ATR unavailable - **Runner:** 40% remaining after TP1 (configurable via `TAKE_PROFIT_1_SIZE_PERCENT=60`) +- **Runner SL after TP1:** ADX-based adaptive positioning (Nov 19, 2025): + - ADX < 20: SL at 0% (breakeven) - Weak trend, preserve TP1 profit + - ADX 20-25: SL at -0.3% - Moderate trend, some retracement room + - ADX > 25: SL at -0.55% - Strong trend, full retracement tolerance + - **Rationale:** Entry at candle close = always at top, natural -1% to -1.5% pullbacks common + - **Risk management:** Only accept runner drawdown on high-probability strong trends + - Worst case examples: ADX 18 → +$38.70 total, ADX 29 → +$22.20 if runner stops (but likely catches big move) - **Trailing Stop:** ATR-based with ADX multiplier (Nov 19, 2025 enhancement): - Base: ATR × 1.5 multiplier - **ADX-based widening (graduated):** @@ -498,9 +505,16 @@ await positionManager.addTrade(activeTrade) **Key behaviors:** - Tracks `ActiveTrade` objects in a Map -- **TP2-as-Runner system**: TP1 (configurable %, default 75%) → TP2 trigger (no close, activate trailing) → Runner (remaining %) with ATR-based trailing stop -- Dynamic SL adjustments: Moves to breakeven after TP1, locks profit at +1.2% -- **On-chain order synchronization:** After TP1 hits, calls `cancelAllOrders()` then `placeExitOrders()` with updated SL price at breakeven (uses `retryWithBackoff()` for rate limit handling) +- **TP2-as-Runner system**: TP1 (configurable %, default 60%) → TP2 trigger (no close, activate trailing) → Runner (remaining 40%) with ATR-based trailing stop +- **ADX-based runner SL after TP1 (Nov 19, 2025):** Adaptive positioning based on trend strength + - ADX < 20: SL at 0% (breakeven) - Weak trend, preserve capital + - ADX 20-25: SL at -0.3% - Moderate trend, some retracement room + - ADX > 25: SL at -0.55% - Strong trend, full retracement tolerance + - **Implementation:** Checks `trade.adxAtEntry` in TP1 handler, calculates SL dynamically + - **Logging:** Shows ADX and selected SL: `🔒 ADX-based runner SL: 29.3 → -0.55%` + - **Rationale:** Entry at candle close = top of candle, -1% to -1.5% pullbacks are normal + - **Data collection:** After 50-100 trades, will optimize ADX thresholds (20/25) based on stop-out rates +- **On-chain order synchronization:** After TP1 hits, calls `cancelAllOrders()` then `placeExitOrders()` with updated SL price (uses `retryWithBackoff()` for rate limit handling) - **ATR-based trailing stop with ADX multiplier (Nov 19, 2025):** - Base calculation: `(atrAtEntry / currentPrice × 100) × trailingStopAtrMultiplier` - **ADX-based widening:** Multiplier adjusted based on trend strength at entry