docs: Add CURRENT ACTIVE SYSTEM section to copilot-instructions.md
MANDATORY section for all AI agents to check first: - Current TradingView indicator: v11 All Filters (filters NOW working) - Signal quality scoring: v9 with direction-specific thresholds - Position management: TP2-as-runner with ATR-based dynamic targets - Adaptive leverage: 10x/5x with LONG 95+, SHORT 90+ thresholds - Verification commands to check what's actually deployed This prevents confusion when multiple implementations exist. User mandate: 'i want this to be a mandatory thing to document'
This commit is contained in:
93
.github/copilot-instructions.md
vendored
93
.github/copilot-instructions.md
vendored
@@ -34,6 +34,99 @@
|
||||
|
||||
---
|
||||
|
||||
## 🎯 CURRENT ACTIVE SYSTEM (Dec 17, 2025) - MANDATORY REFERENCE
|
||||
|
||||
**⚠️ CRITICAL: Always check this section first to know what's currently deployed in production**
|
||||
|
||||
### TradingView Indicator (Signal Generation)
|
||||
- **Active Version:** v11 Money Line All Filters
|
||||
- **File:** `workflows/trading/moneyline_v11_all_filters.pinescript`
|
||||
- **Status:** ✅ PRODUCTION (filters NOW WORKING as of v11.1 - Dec 15, 2025)
|
||||
- **Critical Bug Fixed:** Bug #84 - Filters were calculated but never applied to signal logic (caused $1,000 loss)
|
||||
- **Key Parameters:**
|
||||
* Flip Threshold: 0.15% (trend confirmation)
|
||||
* ADX Minimum: 5 (exhaustive sweep optimal - Dec 17, 2025)
|
||||
* RSI LONG: 55-70 (data-driven from 7-trade analysis)
|
||||
* RSI SHORT: 30-70 (momentum-based, RSI 50+ showed 68.2% WR)
|
||||
* Entry Buffer: 0.10 ATR
|
||||
- **Filter Logic:** `finalLongSignal = buyReady and longOk and adxOk and longBufferOk and rsiLongOk and longPositionOk and volumeOk`
|
||||
- **Last Updated:** Dec 15, 2025 (commit acf103c - v11.1 emergency fix)
|
||||
- **See:** `V11_COMPREHENSIVE_ANALYSIS_DEC17_2025.md` for complete 7-trade performance breakdown
|
||||
|
||||
### Signal Quality Scoring (Bot-Side Filtering)
|
||||
- **Active Version:** v9 Quality Scoring with Direction-Specific Thresholds
|
||||
- **File:** `lib/trading/signal-quality.ts`
|
||||
- **Status:** ✅ PRODUCTION
|
||||
- **Direction-Specific Thresholds:**
|
||||
* **LONG signals:** Quality ≥90 required (higher bar due to bull market bias)
|
||||
* **SHORT signals:** Quality ≥80 required (more permissive, harder to short tops)
|
||||
- **Quality Score Calculation:** 0-100 based on 5 metrics (ATR, ADX, RSI, volumeRatio, pricePosition)
|
||||
- **Timeframe-Aware:** Adjusts thresholds for 5min vs daily charts
|
||||
- **Configuration:** `MIN_SIGNAL_QUALITY_SCORE_LONG=90`, `MIN_SIGNAL_QUALITY_SCORE_SHORT=80` in .env
|
||||
- **Last Updated:** Nov 28, 2025 (direction-specific thresholds implemented)
|
||||
|
||||
### Position Management & Exit Strategy
|
||||
- **Active System:** TP2-as-Runner with ATR-Based Dynamic Targets
|
||||
- **File:** `lib/trading/position-manager.ts` (2,027 lines)
|
||||
- **Status:** ✅ PRODUCTION
|
||||
- **Exit Flow:**
|
||||
1. TP1 at ATR × 2.0 (~0.86%) → Close 60% (configurable via `TAKE_PROFIT_1_SIZE_PERCENT`)
|
||||
2. Move SL to breakeven (ADX-based: 0% for ADX<20, -0.55% for ADX>25)
|
||||
3. TP2 at ATR × 4.0 (~1.72%) → Activate trailing stop (does NOT close position)
|
||||
4. Trailing Stop: ATR × 1.5 with real-time 1-min ADX adjustments + profit acceleration
|
||||
5. Runner (40% default) exits via trailing stop or emergency SL
|
||||
- **Key Features:**
|
||||
* Adaptive trailing: Widens for strong ADX (>30), tightens for weak (<25)
|
||||
* ADX acceleration bonus: +5 points since entry = 1.3× wider trail
|
||||
* Peak tracking: Updates `peakPrice` every 2s for precise trailing calculations
|
||||
- **Critical Bug Fixed:** Bug #87 - State persistence (tp2Hit, trailingStopActive, peakPrice) now bulletproof
|
||||
- **Last Updated:** Dec 17, 2025 (state persistence fix - commit 341341d)
|
||||
|
||||
### Adaptive Leverage System
|
||||
- **Status:** ✅ ACTIVE with direction-specific thresholds
|
||||
- **Configuration:**
|
||||
* `USE_ADAPTIVE_LEVERAGE=true`
|
||||
* `HIGH_QUALITY_LEVERAGE=10` (10× for high-quality signals)
|
||||
* `LOW_QUALITY_LEVERAGE=5` (5× for borderline signals)
|
||||
* `QUALITY_LEVERAGE_THRESHOLD_LONG=95` (LONG threshold)
|
||||
* `QUALITY_LEVERAGE_THRESHOLD_SHORT=90` (SHORT threshold)
|
||||
- **Logic:** Quality score determines leverage tier BEFORE position sizing
|
||||
- **Impact:** 2× profit on high-quality signals vs fixed leverage
|
||||
- **Last Updated:** Dec 1, 2025 (direction-specific thresholds + UI controls)
|
||||
|
||||
### Supporting Systems (All Active)
|
||||
- **Stop Hunt Revenge:** Quality 85+ signals get auto re-entry on reversal (90s confirmation)
|
||||
- **Smart Validation Queue:** Quality 50-89 signals queued for 90-minute price confirmation
|
||||
- **Blocked Signal Tracker:** Collects data on quality-blocked signals for threshold optimization
|
||||
- **Health Monitoring:** 30-second Position Manager verification (detects missing SL orders)
|
||||
- **High Availability:** Secondary server with DNS auto-failover (90s detection)
|
||||
|
||||
### How to Verify What's Active
|
||||
```bash
|
||||
# Check TradingView indicator version in latest trade
|
||||
docker exec trading-bot-postgres psql -U postgres -d trading_bot_v4 -c \
|
||||
"SELECT \"indicatorVersion\", \"signalQualityScore\", \"signalQualityVersion\", \"createdAt\"
|
||||
FROM \"Trade\" ORDER BY \"createdAt\" DESC LIMIT 5;"
|
||||
|
||||
# Check quality thresholds in use
|
||||
cat .env | grep -E "MIN_SIGNAL_QUALITY_SCORE|ADAPTIVE_LEVERAGE"
|
||||
|
||||
# Check Position Manager monitoring status
|
||||
docker logs trading-bot-v4 | grep -E "Position Manager|🏥" | tail -20
|
||||
|
||||
# Verify container deployment timestamp
|
||||
docker logs trading-bot-v4 | grep "Server starting" | head -1
|
||||
```
|
||||
|
||||
**⚠️ MANDATORY: Update this section whenever changing:**
|
||||
- TradingView indicator version or parameters
|
||||
- Quality scoring logic or thresholds
|
||||
- Exit strategy or Position Manager behavior
|
||||
- Adaptive leverage configuration
|
||||
- Any system that affects signal generation or execution
|
||||
|
||||
---
|
||||
|
||||
## 🔍 "DO I ALREADY HAVE THIS?" - Quick Feature Discovery
|
||||
|
||||
**Before implementing ANY feature, check if it already exists!** This system has 70+ features built over months of development.
|
||||
|
||||
Reference in New Issue
Block a user