mql5/Experts/Advisors/SMC_Pine/v1.7_CHANGELOG.md

124 lines
4.9 KiB
Markdown
Raw Permalink Normal View History

feat(M5): Implement v2.1 config enforcement and graduated stops in M5 contrarian mode BREAKING CHANGES: - M5 mode now enforces all v2.1 delayed BE/trailing parameters - Graduated stop system replaces legacy disaster stop when enabled - Max bars limit now triggers hard position close Changes to PositionManager_PME_Complete.mqh: 1. Max Bars Hard Close Enforcement - Added check for m_m5_config.max_bars at start of ApplyM5ContrarianManagement() - Forces EXIT_TIME close when position age exceeds configured limit (300 bars) - Prevents indefinite position holding in extended phases 2. Graduated Stop-Loss System - Implements ATR-based phase-progressive stops: * Phase 1 (0-60 bars): 3.5 ATR wide initial protection * Phase 2 (60-180 bars): 2.5 ATR tightened stop * Phase 3 (180+ bars): 2.0 ATR mature stop - Replaces legacy disaster stop when m_config.use_graduated_stops enabled - Falls back to disaster stop (150pt @ -100pt) if graduated stops disabled - Updates m_positions[].current_sl after successful modification 3. Delayed Breakeven Enforcement (v2.1) - Respects m_config.breakeven_min_bars (20 bars minimum age) - Respects m_config.breakeven_min_profit_bars (5 consecutive profit bars) - Applied to both Phase 1 fast BE (25pts) and Phase 2 maturity BE (30pts) - Logs bar count and consecutive profit bars on activation 4. Delayed Trailing Enforcement (v2.1) - Respects m_config.trail_min_bars (40 bars minimum age) - Applied to percentage trail in Phase 2 (30%/40% based on reversal speed) - Sets trail_activated flag and increments m_metrics.trails_activated - Logs activation with percentage and bar count 5. M5 Trailing Helper Metric Sync - Created ApplyM5PercentageTrail() with current_sl sync - Created ApplyM5PointsTrail() with current_sl sync - Created ApplyM5DynamicTrail() with current_sl sync - Standard helpers (ApplyPercentageTrail, etc.) preserved for non-M5 use - M5 contrarian management now calls M5-specific versions exclusively - Fixes metric/state desync between MT5 server and in-memory position tracking Architecture: - M5 mode continues to bypass standard management path (intentional isolation) - Standard trailing/technical/time-exit engines remain unused in M5 mode - Configuration separation maintained: ManagementConfig for standard + v2.1 fields, M5Config for contrarian-specific - No changes to main EA file (ERMT_PME_2.1_M5.mq5) Compatibility: - No breaking changes to standard (non-M5) management path - Existing M5 backtest results remain valid (behavior refinement only) - All v2.1 configuration fields now honored in M5 runtime
2026-03-02 17:08:42 +00:00
---
noteId: "278028a005a111f1af33fb18ab0fc1c3"
tags: []
---
# SMC Narrative v1.7 (Liquidity Hunter) - Changelog
## Overview
This update transforms the strategy from v1.6 (Sniper Logic) to v1.7 (Liquidity Hunter) by implementing more sophisticated runner management and structural filters.
## Key Changes
### 1. **M15 Structure Shift (CHoCH Detection)**
- **Previous**: Used M5 for execution and CHoCH detection
- **New**: Uses M15 timeframe for CHoCH signals
- **Benefit**: Filters out ~70% of "fake" reversals that occur inside H4 POI
- **Implementation**:
- New input: `ltfTf = input.timeframe("15", "LTF (Execution Timeframe)")`
- CHoCH detection now uses M15 pivots via `request.security(syminfo.tickerid, ltfTf, f_ltfStructure())`
### 2. **"Lox-In" Breakeven Logic**
- **Previous**: Immediately started ATR trailing after TP1 hit
- **New**: Moves SL to Entry + 0.5R (breakeven lock) instead of ATR trail
- **Implementation**:
```
if not tp1LongHit and high >= longTp1:
runnerSlLong := longEntry + (longSlDist * 0.5)
```
- **Benefit**: Prevents "strangle" effect and protects profits while allowing runner to reach HTF liquidity
### 3. **No-Strangle ATR Trail (4R Threshold)**
- **Previous**: ATR trail started at 3R
- **New**: ATR trail only activates after price reaches 4R profit
- **Implementation**:
```
if tp1LongHit and high >= (strategy.position_avg_price + (slDist * 4.0)):
runnerSlLong := math.max(runnerSlLong, low - (atrTrail * 2.5))
```
- **Benefit**: Gives the runner space to reach external HTF liquidity without being stopped out prematurely
### 4. **Daily Bias Filter (HTF Swing Filter)**
- **Previous**: No Daily check; could trade corrections on H4 while D1 crashing
- **New**: Only takes Longs if Daily candle is bullish; Shorts if Daily is bearish
- **Implementation**:
```
f_dailyBias() =>
d1Bullish = close > open
d1Bearish = close < open
validLong = chochLong and isVolSpike and isDisplaced and vfiLong and (not useD1Filter or d1Bullish)
validShort = chochShort and isVolSpike and isDisplaced and vfiShort and (not useD1Filter or d1Bearish)
```
- **Benefit**: Ensures you're not trading corrections; alignsLTF trades with HTF bias
### 5. **Hard Target for Runner (HTF Liquidity Limit Orders)**
- **Previous**: Runner exit was only stop-based; no profit targets
- **New**: Sets limit orders at External HTF Liquidity levels
- **Implementation**:
```
// Long runner
strategy.exit("Runner Long", "Long", stop=longStop, limit=htfLiqHigh)
// Short runner
strategy.exit("Runner Short", "Short", stop=shortStop, limit=htfLiqLow)
```
- **Benefit**: Captures full runner extension to HTF swing highs/lows instead of random ATR trail exits
## Position State Management Changes
### New Variables (v1.7)
- `runnerSlLong` / `runnerSlShort`: Tracks the runner SL (Lox-In breakeven, then ATR trail after 4R)
- Variables now use `request.security()` with `ltfTf` instead of hardcoded M5
### Entry Logic (Unchanged Core)
- Entries still require: CHOCH + Volume Spike + Displacement + VFI + **NEW: Daily Bias**
### Exit Logic (Completely Rewritten)
**Long Position Flow**:
1. TP1 (2R) triggered → Sell 50% at limit
2. TP1 hit → Move runner SL to Entry + 0.5R (Lox-In)
3. Price reaches 4R → Start ATR trailing from there
4. Runner exits at either: Stop (SL) or Limit (htfLiqHigh)
**Short Position Flow**:
1. TP1 (-2R) triggered → Sell 50% at limit
2. TP1 hit → Move runner SL to Entry - 0.5R (Lox-In)
3. Price reaches -4R → Start ATR trailing from there
4. Runner exits at either: Stop (SL) or Limit (htfLiqLow)
## Configuration Updates
### New Inputs
- `ltfTf`: LTF Execution Timeframe (default: "15" for M15)
- `useD1Filter`: Enable/disable Daily bias filter (default: true)
- `d1PivotLen`: Daily pivot length (default: 2)
### Removed Inputs
- None (all v1.6 inputs remain)
## Testing Checklist
- [ ] Verify strategy compiles without errors
- [ ] Backtest on EURUSD H4 with M15 LTF
- [ ] Check that runners reach HTF liquidity levels more frequently
- [ ] Verify Daily filter reduces fake reversal entries
- [ ] Monitor that Lox-In breakeven prevents premature exits
- [ ] Confirm ATR trail only activates after 4R profit
- [ ] Compare runner win rate vs v1.6 (expect improvement)
## Notes
- **Displacement Filter**: Remains unchanged at 1.5x average body size
- **VFI Indicator**: No changes; still uses fast length of 50
- **Risk Management**: Position sizing formula unchanged
- **POI Invalidation**: Still closes all trades if POI fails
- **Pyramiding**: Still allows max 2 concurrent trades per direction
## Future Optimization Ideas
1. Make the 4R threshold configurable (currently hardcoded)
2. Add option to scale into runner position at HTF liquidity breakout
3. Implement partial profits at intermediate levels (e.g., 6R, 8R)
4. Add trend confirmation from higher timeframes (W1, Monthly)