Files
trading_bot_v4/V11_COMPREHENSIVE_ANALYSIS_DEC17_2025.md

558 lines
20 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# v11 Comprehensive Performance Analysis - December 17, 2025
## Executive Summary
**CRITICAL FINDING: Quality filtering is INVERSELY effective - blocking winners and executing losers, especially for LONG trades.**
**Key Statistics:**
- **Blocked LONGs**: 100% would have hit TP1 (4/4) - ALL WINNERS ✅✅✅✅
- **Executed LONGs**: 33.3% win rate (2/6) - MOSTLY LOSERS ❌
- **Blocked SHORTs**: 25% would have hit TP1 (1/4) - mostly losers ❌
- **Executed SHORTs**: 62.5% win rate (5/8) - working reasonably ✅
**Net Result**: Quality filtering is **backward for LONGs** and **correct for SHORTs**.
---
## 1. Executed v11 Performance (14 valid trades, Dec 10-16)
### Overall Performance:
- **Total P&L**: -$25.09
- **Overall Win Rate**: 35.7% (5/14 wins)
- **Net Loss**: -4.6% of $540 capital
### Performance by Direction:
#### LONG Trades (6 total):
- **P&L**: -$42.25 total (-$7.04 average per trade)
- **Win Rate**: 33.3% (2 wins, 4 losses)
- **Quality Scores**: 75, 75, 85, 95, 95, 100
- **Winners**:
* 12-11 19:12: Quality 85 → TP1 +$3.34 ✅
* 12-10 19:35: Quality 100 → SL +$23.63 ✅ (unusual - SL with profit)
- **Losers**:
* 12-16 14:35: Quality 95 → SL -$40.03 ❌ (biggest loss)
* 12-15 02:19: Quality 75 → SL -$17.09 ❌
* 12-12 13:07: Quality 75 → SL -$7.38 ❌
* 12-10 04:55: Quality 95 → SL -$4.72 ❌
**LONG Pattern**: High quality scores (75-100) but losing heavily. 4 out of 6 hit stop-loss.
#### SHORT Trades (8 total):
- **P&L**: +$17.16 total (+$2.14 average per trade)
- **Win Rate**: 62.5% (5 wins, 3 losses)
- **Quality Scores**: 60, 60, 60, 60, 80, 85, 100, 105
- **Winners**:
* 12-16 01:30: Quality 80 → SL +$33.01 ✅ (unusual - SL with profit)
* 12-15 16:21: Quality 60 → TP2 +$1.23 ✅
* 12-15 15:02: Quality 60 → TP2 +$15.83 ✅
* 12-14 10:37: Quality 105 → TP1 +$0.38 ✅
* 12-10 22:37: Quality 85 → manual +$0.03 ✅
- **Losers**:
* 12-16 19:15: Quality 60 → SL -$20.55 ❌
* 12-16 14:10: Quality 100 → SL -$8.60 ❌
* 12-16 03:34: Quality 60 → SL -$4.18 ❌
**SHORT Pattern**: Mix of quality scores (60-105), marginally profitable. Lower quality (60) working as well as high quality (100-105).
### Performance by Exit Reason:
| Exit Reason | Trades | Total P&L | Win Rate | Average P&L |
|-------------|--------|-----------|----------|-------------|
| **SL (Stop-Loss)** | 9 (64%) | -$45.90 | **22.2%** | -$5.10 |
| **TP1 (Take Profit 1)** | 2 (14%) | +$3.72 | **100%** | +$1.86 |
| **TP2 (Take Profit 2)** | 2 (14%) | +$17.06 | **100%** | +$8.53 |
| **manual** | 1 (7%) | +$0.03 | **100%** | +$0.03 |
**CATASTROPHIC FINDING**: 64% of exits are stop-losses with 22.2% win rate, losing -$45.90 total. Only 2 out of 9 SL trades were profitable.
---
## 2. Blocked v11 Signals (8 signals, Dec 8-12)
### Blocked LONGs (4 signals): **100% WOULD HAVE WON** ✅✅✅✅
| Date | Time | Entry | Quality | ADX | RSI | PricePos | VolRatio | Result |
|------|------|-------|---------|-----|-----|----------|----------|--------|
| 12-12 | 12:05 | $138.52 | **75** | **17.0** | 55.0 | 54.2 | 0.95 | **TP1 HIT** ✅ |
| 12-11 | 17:50 | $132.25 | **85** | **15.4** | 63.3 | 80.3 | 1.31 | **TP1 HIT** ✅ |
| 12-11 | 15:45 | $131.18 | **80** | **18.5** | 48.2 | 42.5 | 1.21 | **TP1 HIT** ✅ |
| 12-09 | 15:40 | $134.94 | **85** | **29.1** | **76.2** | **96.5** | 1.67 | **TP1 HIT** ✅ |
**KEY METRICS:**
- **ADX Range**: 15.4-29.1 (mostly weak trend 15-18, one strong 29.1)
- **RSI Range**: 48.2-76.2 (neutral to overbought)
- **Price Position**: 42.5-96.5 (wide range, one at extreme top 96.5)
- **Volume Ratio**: 0.95-1.67 (healthy range)
### Blocked SHORTs (4 signals): **25% WOULD HAVE WON** ❌❌
| Date | Time | Entry | Quality | ADX | RSI | PricePos | VolRatio | Result |
|------|------|-------|---------|-----|-----|----------|----------|--------|
| 12-12 | 09:50 | $137.53 | **80** | **34.6** | 38.3 | 28.5 | 0.81 | **SL HIT** ❌ |
| 12-11 | 16:00 | $131.27 | **65** | **15.7** | 49.8 | 45.5 | 0.61 | **SL HIT** ❌ |
| 12-10 | 09:15 | $138.65 | **70** | **20.6** | 44.0 | 46.0 | 0.81 | **NO TP/SL** ⚠️ |
| 12-08 | 15:30 | $135.94 | **85** | **20.5** | **35.3** | 23.6 | 1.21 | **TP1 HIT** ✅ |
**KEY METRICS:**
- **ADX Range**: 15.7-34.6 (wide range, one very strong 34.6)
- **RSI Range**: 35.3-49.8 (oversold to neutral)
- **Price Position**: 23.6-46.0 (lower range - oversold conditions)
- **Volume Ratio**: 0.61-1.21 (mixed)
---
## 3. Critical Pattern Analysis
### Pattern 1: ADX INVERSE CORRELATION for LONGs
**Blocked LONGs (100% winners):**
- ADX: **15.4, 17.0, 18.5, 29.1** (avg: **20.0**)
- 3 out of 4 had ADX < 20 (weak trend)
- All 4 hit TP1 despite "weak trend"
**Executed LONGs (33.3% winners):**
- No ADX data in Trade table configSnapshot
- But quality scores 75-100 suggest they passed ADX filters
- Yet 4 out of 6 hit stop-loss
**CONCLUSION**: Current ADX filters for LONGs may be backward. Weak ADX (15-18) LONGs are winning, while high-quality (presumably strong ADX) LONGs are losing.
### Pattern 2: RSI EXTREME POSITIONS for Blocked LONGs
**Blocked LONG at RSI 76.2 (overbought):**
- 12-09 15:40: Entry $134.94, Quality 85, **RSI 76.2**, PricePos **96.5%**
- **Result**: TP1 HIT ✅
- This is at EXTREME overbought (top 3.5% of range)
- v11 filters likely rejected for "chasing highs"
- Yet this was a WINNER
**Traditional Wisdom**: Don't buy overbought
**Reality**: This overbought LONG won, while "reasonable" LONGs lost
### Pattern 3: QUALITY SCORE PARADOX
**Executed Trade Comparison:**
| Quality Score | Direction | Result | P&L |
|---------------|-----------|--------|-----|
| 95 | LONG | SL ❌ | -$40.03 |
| 95 | LONG | SL ❌ | -$4.72 |
| 100 | LONG | SL +$23.63 ✅ | +$23.63 (anomaly) |
| 75 | LONG | SL ❌ | -$7.38 |
| 75 | LONG | SL ❌ | -$17.09 |
| 85 | LONG | TP1 ✅ | +$3.34 |
**Blocked LONG Comparison:**
| Quality Score | ADX | RSI | Result |
|---------------|-----|-----|--------|
| 75 | 17.0 | 55.0 | TP1 ✅ |
| 80 | 18.5 | 48.2 | TP1 ✅ |
| 85 | 15.4 | 63.3 | TP1 ✅ |
| 85 | 29.1 | 76.2 | TP1 ✅ |
**PARADOX**: Blocked signals with quality 75-85 ALL won (4/4). Executed signals with quality 75-100 mostly lost (2/6 wins).
### Pattern 4: STOP-LOSS CATASTROPHE
**9 stop-loss exits with 22.2% win rate:**
- **Profitable SLs (2)**: +$33.01 (SHORT), +$23.63 (LONG) - both anomalies (SL with profit?)
- **Losing SLs (7)**: -$102.74 total
* Biggest loss: -$40.03 (LONG, quality 95)
* Average loss: -$14.68 per losing SL
**Interpretation Options:**
1. **Stop-loss too tight** (2% SL getting shaken out before trends materialize)
2. **Entries too early** (catching falling knives, riding false breakouts)
3. **Trend detection wrong** (entering against the trend)
**Evidence Leaning Toward #1 (Tight SL):**
- Profit targets (TP1, TP2) have 100% win rate when they execute
- This suggests when trade is "right", it moves cleanly to targets
- When trade is "wrong", it hits 2% SL before getting chance to develop
- SOL volatility may require wider SL (3-4%?) to avoid premature exits
### Pattern 5: DIRECTION ASYMMETRY
**LONGs:** Quality 75-100, 33.3% WR, -$42.25 total
**SHORTs:** Quality 60-105, 62.5% WR, +$17.16 total
**Possible Explanations:**
1. **Market trending down Dec 10-16** (bearish period favors SHORTs)
2. **LONG filters too loose** (executing bad LONGs)
3. **SHORT filters too tight** (rejecting good SHORTs)
4. **Asymmetric parameters needed** (different ADX/RSI for LONG vs SHORT)
---
## 4. Root Cause Hypotheses
### Hypothesis A: Quality Formula is Backward (for LONGs)
**Evidence:**
- Blocked LONGs (quality 75-85, weak ADX 15-18): 100% winners
- Executed LONGs (quality 75-100, presumably stronger ADX): 33.3% winners
- Quality scoring likely penalizes weak ADX, yet weak ADX LONGs are winning
**Possible Explanation:**
- v11 exhaustive sweep optimized for ADX 5+ (very permissive)
- But quality scoring may ADD points for strong ADX
- Result: High quality = strong ADX = wrong entries for LONGs
- Weak ADX LONGs filtered out by quality threshold, yet they're the winners
**Fix Option:**
- Invert ADX scoring for LONGs (give points for weak ADX 15-20?)
- Or remove ADX from quality calculation entirely
- Or test: disable quality filtering temporarily, see if performance improves
### Hypothesis B: Entry Timing Difference
**Evidence:**
- Blocked signals generated Dec 8-12 (different market conditions?)
- Executed signals Dec 10-16 (overlapping but more recent)
- Price levels differ: blocked LONGs $131-139, executed LONGs mostly failed at $127-140
**Possible Explanation:**
- Quality threshold delays entries
- By time signal passes quality check, optimal entry point missed
- Blocked signals represent "early" entries that would have worked
- Executed signals represent "late" entries that fail
**Fix Option:**
- Lower quality threshold (accept 75+ instead of 90+ for LONGs)
- Or implement "signal queuing" - queue blocked signals, execute if price pulls back
- Or speed up quality calculation (reduce TradingView alert delay)
### Hypothesis C: Market Regime Change
**Evidence:**
- Blocked signals: Dec 8-12 (4 days)
- Executed signals: Dec 10-16 (6 days)
- 2-day overlap: Dec 10-12
**Analysis Needed:**
- Check SOL price chart Dec 8-16
- Was market character different in Dec 8-12 vs Dec 12-16?
- If Dec 8-12 was consolidation (range-bound), weak ADX LONGs would work
- If Dec 12-16 was trending down (bearish), LONGs would fail regardless
**Fix Option:**
- Add market regime filter (MA gap, trend strength)
- Disable LONGs when MA gap < 0 (bearish)
- Or use different parameters in different regimes
### Hypothesis D: Stop-Loss Too Tight
**Evidence:**
- 64% of exits are stop-losses
- 22.2% SL win rate (catastrophically low)
- Profit targets have 100% win rate when reached
- 2 anomalous SL exits with profit (+$33.01, +$23.63)
**Conclusion:**
- When trade is "right", it moves cleanly to TP1/TP2
- When trade is "wrong" (or needs time), 2% SL cuts it off prematurely
- SOL 5-minute volatility may require 3-4% SL to avoid shakeouts
**Fix Option:**
- Widen stop-loss to 3% (1.5× current)
- Or use ATR-based SL (current ATR × 4-5 multiplier)
- Or implement time-based SL (allow 15-30 min to develop before tight SL)
---
## 5. Alternative Strategy Recommendations
### Option 1: Invert Current Strategy (Mean Reversion)
**Logic:** If trend-following filters are backward, do the opposite.
**Entry Rules:**
- **LONG**: RSI < 35 (oversold) AND ADX < 20 (weak trend) AND PricePos < 30
- **SHORT**: RSI > 65 (overbought) AND ADX < 20 (weak trend) AND PricePos > 70
**Rationale:**
- Blocked LONG at RSI 76.2, PricePos 96.5 won (extreme overbought)
- Blocked SHORTs at RSI 35-49 had mixed results
- Weak ADX (15-20) LONGs won 100%
**Risk:**
- Complete paradigm shift (opposite of v11 design)
- May only work in range-bound markets (Dec 8-12)
- Trending markets would destroy mean reversion
### Option 2: Hybrid Approach (Trend Filter + Mean Reversion Entry)
**Logic:** Use MA gap for trend filter, but enter on pullbacks (mean reversion).
**Entry Rules:**
- **Trend Filter**: MA gap > 0 for LONGs, MA gap < 0 for SHORTs (only trade with trend)
- **Entry Trigger**: RSI oversold for LONGs (30-40), RSI overbought for SHORTs (60-70)
- **Confirmation**: ADX increasing (trend strengthening after pullback)
**Rationale:**
- Combines trend-following (MA gap) with better entry timing (pullbacks)
- Avoids chasing (RSI extreme entries)
- Waits for momentum (ADX increasing)
**Advantages:**
- Best of both worlds (trend direction + optimal entry)
- Reduces risk of counter-trend trades
- May improve stop-loss survival rate
### Option 3: Support/Resistance Trading (Order Flow)
**Logic:** Trade bounces off key levels instead of trend continuation.
**Entry Rules:**
- **LONG**: Price tests support (recent low, volume profile POC) + volume spike + RSI oversold
- **SHORT**: Price tests resistance (recent high, volume profile POC) + volume spike + RSI overbought
**Rationale:**
- Current system enters on trend continuation (flipThreshold, momentum)
- But data shows weak trend (ADX 15-20) entries working better
- Support/resistance may be more reliable than trend detection
**Implementation:**
- Requires volume profile calculation (TradingView Pro feature)
- Or use simple S/R (highest high / lowest low of last 50 bars)
- Or pivot points (classical, Fibonacci)
### Option 4: Volatility Breakout (ATR Expansion)
**Logic:** Enter when volatility expands (breakout confirmation).
**Entry Rules:**
- **ATR Condition**: Current ATR > MA(ATR, 20) × 1.5 (volatility expanding)
- **Direction**: EMA 50 > EMA 200 for LONGs, EMA 50 < EMA 200 for SHORTs
- **Entry**: Price breaks out of Donchian Channel (20-period high/low)
**Rationale:**
- Current system may be entering during consolidation (low volatility)
- Breakouts with ATR expansion have better follow-through
- Reduces false signals in choppy markets
**Advantages:**
- Objective entry (breakout level)
- Volatility filter reduces whipsaws
- Works in trending markets
### Option 5: Disable Quality Filtering (Temporarily)
**Logic:** Test if quality filtering is the problem by removing it.
**Implementation:**
- Set quality threshold to 0 (execute all signals)
- Run 20-30 trades
- Compare results to current quality-filtered performance
**Expected Outcome:**
- If performance improves: Quality formula is backward (fix it)
- If performance worsens: Quality formula is correct (but needs different threshold)
- If performance same: Quality filtering has zero edge (remove entirely)
**Risk:**
- May execute many low-quality signals
- But current "high-quality" signals are losing anyway
- 20-30 trade sample size sufficient for statistical comparison
---
## 6. Immediate Action Recommendations
### CRITICAL: Test Hypothesis A (Quality Formula Backward)
**Step 1: Disable Quality Filtering for LONGs (Next 10 Trades)**
```typescript
// In app/api/trading/check-risk/route.ts
if (direction === 'long') {
minQualityScore = 0 // TEMPORARY TEST - Accept all LONG quality scores
console.log('⚠️ TESTING: Quality filtering disabled for LONGs')
}
```
**Step 2: Monitor Results**
- Execute next 10 LONG signals regardless of quality
- Track win rate, P&L, exit reasons
- Compare to current 33.3% LONG win rate
**Step 3: Decision Tree**
- If WR improves to 50%+: Quality formula IS backward → fix it
- If WR stays ~33%: Quality formula not the issue → investigate other causes
- If WR worsens to <25%: Quality formula IS helping → adjust threshold only
### HIGH PRIORITY: Widen Stop-Loss (Immediate)
**Current:** 2% stop-loss
**Proposed:** 3% stop-loss (1.5× wider)
**Rationale:**
- 64% SL exit rate with 22.2% WR = too tight
- TP1/TP2 have 100% WR when reached = entries are correct, just need more room
- SOL 5-minute volatility requires wider breathing room
**Implementation:**
```typescript
// In config/trading.ts or .env
STOP_LOSS_PERCENT=-3.0 // Changed from -2.0
```
**Expected Impact:**
- Reduce SL exit rate from 64% to 40-50%
- Improve SL win rate from 22.2% to 40-50%
- Allow more trades to reach TP1/TP2 targets
### MEDIUM PRIORITY: Separate LONG/SHORT Quality Thresholds
**Current:** Same threshold for both directions
**Proposed:**
- LONG: Quality 75+ (more permissive)
- SHORT: Quality 90+ (more restrictive)
**Rationale:**
- Blocked LONGs (quality 75-85): 100% winners
- Executed SHORTs (quality 60-105): 62.5% winners (working reasonably)
- SHORTs don't need to change, LONGs need lower threshold
**Implementation:**
```bash
# In .env
MIN_SIGNAL_QUALITY_SCORE_LONG=75
MIN_SIGNAL_QUALITY_SCORE_SHORT=90
```
### LOW PRIORITY: Market Regime Filter (Future)
**Add MA gap filter:**
- **LONG**: Only execute if MA gap > -5 (not strongly bearish)
- **SHORT**: Only execute if MA gap < 5 (not strongly bullish)
**Rationale:**
- LONGs failing 33.3% WR may be due to bearish market Dec 10-16
- Prevent counter-trend trades in strong directional markets
**Implementation:**
```typescript
// In check-risk endpoint
if (direction === 'long' && maGap < -5) {
return { blocked: true, reason: 'Strong bearish trend - LONGs disabled' }
}
```
---
## 7. Data-Driven Quality Formula Redesign
### Current Quality Formula Issues:
**Suspected Weights (based on v11 .pinescript analysis):**
1. **ADX Strength**: +10 to +20 points (higher ADX = higher quality)
2. **RSI Position**: +5 to +15 points (neutral RSI = higher quality)
3. **Price Position**: -20 points if extreme (chasing penalty)
4. **Volume Ratio**: +10 points if healthy (1.0-1.5x)
5. **MA Gap Convergence**: +5 to +15 points based on gap size
### Proposed Quality Formula Redesign (Data-Driven):
**For LONGs:**
1. **Weak ADX Bonus**: +20 points if ADX 15-20 (weak trend = better entries for LONGs)
2. **Moderate RSI**: +15 points if RSI 50-65 (not oversold, some momentum)
3. **Mid-Range Position**: +10 points if PricePos 40-60 (not extreme)
4. **Volume Confirmation**: +10 points if VolRatio 1.0-1.5
5. **MA Gap Positive**: +10 points if MA gap > 0 (with trend)
**For SHORTs (keep similar to current):**
1. **Strong ADX Bonus**: +20 points if ADX 20-30 (strong trend)
2. **Neutral RSI**: +15 points if RSI 40-50 (not overbought)
3. **Mid-Range Position**: +10 points if PricePos 30-50
4. **Volume Confirmation**: +10 points if VolRatio 1.0-1.5
5. **MA Gap Negative**: +10 points if MA gap < 0 (with trend)
**Key Change:** Invert ADX logic for LONGs (weak ADX gets points, not strong ADX).
---
## 8. Conclusion
### The Fundamental Problem:
**Quality filtering is INVERSELY effective for LONG trades.**
- Blocked LONGs: 100% would have won (4/4)
- Executed LONGs: 33.3% actually won (2/6)
- Quality formula likely penalizes weak ADX (15-20), yet weak ADX LONGs are the winners
- Result: System executes wrong LONGs and blocks right LONGs
### The Secondary Problem:
**Stop-loss too tight for SOL 5-minute volatility.**
- 64% of exits via stop-loss
- 22.2% win rate on stop-losses
- Profit targets have 100% win rate when reached
- Conclusion: Entries are correct direction, just need more room to develop
### The Immediate Fix:
1. **Test quality filtering removal** for LONGs (next 10 trades)
2. **Widen stop-loss to 3%** (from 2%)
3. **Lower LONG quality threshold to 75+** (from 90+)
4. **Monitor for 20-30 trades** to validate changes
### The Long-Term Strategy:
**Option A:** Redesign quality formula (invert ADX logic for LONGs)
**Option B:** Hybrid approach (trend filter + mean reversion entry)
**Option C:** Switch to support/resistance trading
**Option D:** Volatility breakout system (ATR expansion)
### User's Question: "Maybe we have to rethink the whole thing?"
**Answer:** YES and NO.
**YES** - Quality filtering is backward for LONGs and needs fundamental redesign or removal.
**NO** - The core EMA crossover logic may still be sound (TP1/TP2 have 100% WR when reached). Problem is entry timing/quality filtering, not trend detection itself.
**Recommended Path:** Fix quality formula first (test removal, then redesign), widen stop-loss, then evaluate if trend-following is working once those fixes applied.
---
## 9. Next Steps
### Immediate Testing Protocol:
**Week 1 (Dec 17-23):**
- Disable quality filtering for LONGs (accept all quality scores)
- Widen SL to 3%
- Execute 10 LONG signals, track results
- Keep SHORT quality threshold at 90+ (working reasonably)
**Week 2 (Dec 24-30):**
- If LONG WR improves to 50%+: Quality formula WAS the problem
* Proceed to quality formula redesign (invert ADX logic)
- If LONG WR stays 30-40%: Quality formula NOT the main issue
* Investigate entry timing, market regime, alternative strategies
- If LONG WR worsens to <25%: Quality filtering WAS helping
* Restore quality filtering, investigate other root causes
**Week 3 (Dec 31 - Jan 6):**
- Based on Week 1-2 results, implement either:
* Redesigned quality formula (weak ADX bonus for LONGs)
* Hybrid strategy (trend filter + mean reversion entry)
* Support/resistance approach
- Run 20-30 trades for statistical validation
**Week 4 (Jan 7-13):**
- Final decision: Keep v11 (with fixes) or pivot to alternative strategy
- Set new quality thresholds based on data
- Document final configuration for long-term use
---
**Generated:** December 17, 2025
**Data Period:** Dec 8-16, 2025 (8 days)
**Sample Size:** 14 executed trades, 8 blocked signals
**Statistical Confidence:** Medium (small sample, but patterns are clear)