docs: Add Pyramiding/Position Stacking implementation plan
- Create comprehensive PYRAMIDING_IMPLEMENTATION_PLAN.md with: - Data-driven justification (100% WR for signals ≤72 bars apart) - User-selected parameters (4h window, 7x→14x leverage) - ENV variables, database schema, execute endpoint logic - Position manager updates, Telegram notifications - 7-phase implementation checklist - 4 expected behavior examples - Add reference in copilot-instructions.md under Development Roadmap - Documents planned pyramiding system - Links to implementation plan for future agent
This commit is contained in:
72
.github/copilot-instructions.md
vendored
72
.github/copilot-instructions.md
vendored
@@ -5947,6 +5947,78 @@ All technical improvements must align with current phase objectives (see top of
|
||||
- Comparison with executed trades at similar quality levels
|
||||
- Future automation of price tracking (would TP1/TP2/SL have hit?)
|
||||
|
||||
---
|
||||
|
||||
## 🔺 Pyramiding/Position Stacking System (Jan 6, 2026 - PLANNED)
|
||||
|
||||
**Status:** 📋 PLANNED - Implementation plan ready, awaiting development
|
||||
|
||||
**Purpose:** Scale into winning positions by adding to existing trades when confirmation signals arrive within a time window. Based on ML v11.2 backtesting analysis showing 100% win rate for signals ≤72 bars apart.
|
||||
|
||||
**Implementation Plan:** See `docs/PYRAMIDING_IMPLEMENTATION_PLAN.md` for complete details
|
||||
|
||||
**Key Parameters (User-Selected):**
|
||||
- **Stacking Window:** 4 hours (240 minutes / 48 bars on 5-min chart)
|
||||
- **Base Leverage:** 7x (first entry)
|
||||
- **Stack Leverage:** 7x (additional entry)
|
||||
- **Max Total Leverage:** 14x (7x + 7x = 2 pyramid levels)
|
||||
- **Max Pyramid Levels:** 2 (base + 1 stack)
|
||||
|
||||
**Data-Driven Justification:**
|
||||
- Backtesting analysis of ML v11.2 pyramiding trades
|
||||
- **≤72 bars (6 hours):** 100% win rate - signals close together confirm trend
|
||||
- **>72 bars:** 67.6% win rate - too far apart, trend may have reversed
|
||||
- User chose conservative 48-bar (4-hour) window for production
|
||||
|
||||
**Environment Variables (New):**
|
||||
```bash
|
||||
ENABLE_PYRAMIDING=true
|
||||
BASE_LEVERAGE=7
|
||||
STACK_LEVERAGE=7
|
||||
MAX_LEVERAGE_TOTAL=14
|
||||
MAX_PYRAMID_LEVELS=2
|
||||
STACKING_WINDOW_MINUTES=240
|
||||
```
|
||||
|
||||
**Database Schema Changes:**
|
||||
```prisma
|
||||
model Trade {
|
||||
// ... existing fields
|
||||
pyramidLevel Int? // 1 = base, 2 = first stack, etc.
|
||||
parentTradeId String? // Links stacked trades to base
|
||||
stackedAt DateTime? // When stack was added
|
||||
totalLeverageAtEntry Float? // Running total leverage
|
||||
isStackedPosition Boolean @default(false)
|
||||
}
|
||||
```
|
||||
|
||||
**Core Logic:**
|
||||
1. First signal → Open position with 7x leverage (pyramidLevel: 1)
|
||||
2. Second signal within 4 hours → Check if same direction + within window
|
||||
3. If valid → Add 7x position (pyramidLevel: 2), total leverage now 14x
|
||||
4. Position Manager tracks both as linked positions
|
||||
5. Exit → Close ALL pyramid levels together (unified exit)
|
||||
|
||||
**Safety Checks:**
|
||||
- ✅ Same direction only (no hedging)
|
||||
- ✅ Within stacking window (4 hours default)
|
||||
- ✅ Max leverage cap (14x)
|
||||
- ✅ Max pyramid levels (2)
|
||||
- ✅ Sufficient free collateral for additional position
|
||||
|
||||
**TradingView Strategy (Already Implemented):**
|
||||
- File: `workflows/trading/moneyline_v11_2_strategy.pinescript`
|
||||
- Has pyramiding=1 setting and barSpacingThreshold input
|
||||
- Debug table shows bar spacing and stacking decisions
|
||||
|
||||
**References:**
|
||||
- Implementation plan: `docs/PYRAMIDING_IMPLEMENTATION_PLAN.md`
|
||||
- TradingView strategy: `workflows/trading/moneyline_v11_2_strategy.pinescript`
|
||||
- Backtesting data: `backtester/dynamic_threshold_backtest_20251223_152614.csv`
|
||||
- Analysis document: `V11_COMPREHENSIVE_ANALYSIS_DEC17_2025.md`
|
||||
|
||||
---
|
||||
|
||||
## Telegram Notifications (Nov 16, 2025 - Enhanced Nov 20, 2025)
|
||||
|
||||
**Position Closure Notifications:** System sends direct Telegram messages for all position closures via `lib/notifications/telegram.ts`
|
||||
|
||||
Reference in New Issue
Block a user