mql5/Indicators/Examples
darashikoh 428fd88c60 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
..
Canvas 2026-01-31 12:29:07 +00:00
Panels 2026-01-31 12:29:07 +00:00
.DS_Store feat(M5): Implement v2.1 config enforcement and graduated stops in M5 contrarian mode 2026-03-02 17:08:42 +00:00
Accelerator.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Accelerator.mq5 2026-01-31 12:29:07 +00:00
AD.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
AD.mq5 2026-01-31 12:29:07 +00:00
ADX.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ADX.mq5 2026-01-31 12:29:07 +00:00
ADXW.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ADXW.mq5 2026-01-31 12:29:07 +00:00
Alligator.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Alligator.mq5 2026-01-31 12:29:07 +00:00
AMA.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
AMA.mq5 2026-01-31 12:29:07 +00:00
ASI.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ASI.mq5 2026-01-31 12:29:07 +00:00
ATR.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ATR.mq5 2026-01-31 12:29:07 +00:00
Awesome_Oscillator.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Awesome_Oscillator.mq5 2026-01-31 12:29:07 +00:00
BB.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
BB.mq5 2026-01-31 12:29:07 +00:00
Bears.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Bears.mq5 2026-01-31 12:29:07 +00:00
Bulls.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Bulls.mq5 2026-01-31 12:29:07 +00:00
BW-ZoneTrade.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
BW-ZoneTrade.mq5 2026-01-31 12:29:07 +00:00
CCI.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
CCI.mq5 2026-01-31 12:29:07 +00:00
CHO.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
CHO.mq5 2026-01-31 12:29:07 +00:00
CHV.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
CHV.mq5 2026-01-31 12:29:07 +00:00
ColorBars.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ColorBars.mq5 2026-01-31 12:29:07 +00:00
ColorCandlesDaily.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ColorCandlesDaily.mq5 2026-01-31 12:29:07 +00:00
ColorLine.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ColorLine.mq5 2026-01-31 12:29:07 +00:00
Custom Moving Average.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Custom Moving Average.mq5 2026-01-31 12:29:07 +00:00
DEMA.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
DEMA.mq5 2026-01-31 12:29:07 +00:00
DeMarker.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
DeMarker.mq5 2026-01-31 12:29:07 +00:00
DPO.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
DPO.mq5 2026-01-31 12:29:07 +00:00
Envelopes.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Envelopes.mq5 2026-01-31 12:29:07 +00:00
Force_Index.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Force_Index.mq5 2026-01-31 12:29:07 +00:00
Fractals.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Fractals.mq5 2026-01-31 12:29:07 +00:00
FrAMA.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
FrAMA.mq5 2026-01-31 12:29:07 +00:00
Gator.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Gator.mq5 2026-01-31 12:29:07 +00:00
Gator_2.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Gator_2.mq5 2026-01-31 12:29:07 +00:00
Heiken_Ashi.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Heiken_Ashi.mq5 2026-01-31 12:29:07 +00:00
Ichimoku.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Ichimoku.mq5 2026-01-31 12:29:07 +00:00
MACD.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
MACD.mq5 2026-01-31 12:29:07 +00:00
MarketFacilitationIndex.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
MarketFacilitationIndex.mq5 2026-01-31 12:29:07 +00:00
MFI.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
MFI.mq5 2026-01-31 12:29:07 +00:00
MI.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
MI.mq5 2026-01-31 12:29:07 +00:00
Momentum.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Momentum.mq5 2026-01-31 12:29:07 +00:00
OBV.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
OBV.mq5 2026-01-31 12:29:07 +00:00
OsMA.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
OsMA.mq5 2026-01-31 12:29:07 +00:00
ParabolicSAR.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ParabolicSAR.mq5 2026-01-31 12:29:07 +00:00
Price_Channel.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Price_Channel.mq5 2026-01-31 12:29:07 +00:00
PVT.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
PVT.mq5 2026-01-31 12:29:07 +00:00
ROC.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ROC.mq5 2026-01-31 12:29:07 +00:00
RSI.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
RSI.mq5 2026-01-31 12:29:07 +00:00
RVI.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
RVI.mq5 2026-01-31 12:29:07 +00:00
StdDev.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
StdDev.mq5 2026-01-31 12:29:07 +00:00
Stochastic.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Stochastic.mq5 2026-01-31 12:29:07 +00:00
TEMA.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
TEMA.mq5 2026-01-31 12:29:07 +00:00
TRIX.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
TRIX.mq5 2026-01-31 12:29:07 +00:00
Ultimate_Oscillator.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Ultimate_Oscillator.mq5 2026-01-31 12:29:07 +00:00
VIDYA.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
VIDYA.mq5 2026-01-31 12:29:07 +00:00
Volumes.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
Volumes.mq5 2026-01-31 12:29:07 +00:00
VROC.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
VROC.mq5 2026-01-31 12:29:07 +00:00
W_AD.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
W_AD.mq5 2026-01-31 12:29:07 +00:00
WPR.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
WPR.mq5 2026-01-31 12:29:07 +00:00
ZigZag.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ZigZag.mq5 2026-01-31 12:29:07 +00:00
ZigzagColor.ex5 Commit from local main repo as cannot checkout due to some unsaved version - which ones is unclear 2025-08-19 18:36:26 +01:00
ZigzagColor.mq5 2026-01-31 12:29:07 +00:00