Dynamic Channel (Box Trading) — Price Tunnel

6. Dynamic Channel (Box Trading) — Price Tunnel

Restricts the trading zone to a dynamically defined price corridor.

Standard Box (Long-Term)

Updated every Inp_Channel_Update_Hours hours (default 6h):

  1. Records the current BID price as base_price
  2. g_Channel_Upper = base_price + Channel_Points_Up × _Point
  3. g_Channel_Lower = base_price - Channel_Points_Down × _Point
  4. Trading is only allowed when price is inside the channel

Default settings: Upper +20,000 pts, Lower −5,000 pts — an asymmetric channel assuming greater upside potential.

Log: "NEW STANDARD PRICE CHANNEL: Base: 2100.50 | Upper: 2300.50 | Lower: 2050.50"

Manual Box (Anti-Crash Protection)

Inp_ManualBox_Enable = true allows the trader to manually define absolute price boundaries:

  • Inp_ManualBox_Upper — upper boundary (price)
  • Inp_ManualBox_Lower — lower boundary (price)

Use case: the trader can manually define a tunnel before a major fundamental event or when operating in a specific market regime.

Channel Priority (IsPriceInChannel)

1. Muzzle Box (active during Impulse) — HIGHEST PRIORITY
2. Manual Box (if Inp_ManualBox_Enable = true)
3. Standard Dynamic Channel (if Inp_Channel_Enable = true)

Status displayed on the panel as g_Status_Channel.

Architecture & Module Connections

1. Architecture & Module Connections

The system is composed of five header files included into the compiled main file _AHS_Main.ex5:

_AHS_Main.ex5
  ├── AHS_Inputs.mqh      → All input parameters, enumerations, global state variables
  ├── AHS_Filters.mqh     → Market filters (The Shield): Macro Matrix, Impulse, Channel, ADX/MA, SmartDI, MTF, 3Candles
  ├── AHS_Strategy.mqh    → Multi-Core Engine: position sizing, order execution
  ├── AHS_Management.mqh  → Position management: TSL BB, Hard BE, Neg BE, Dynamic TP, EOD Terminator
  └── AHS_Panel.mqh       → Graphical information panel: status, MTF dashboard, positions list

OnTick() Flow — Step by Step

Every incoming tick passes through a strictly defined sequence in the main loop:

OnTick()
  1.  License check (CLicenseManager.IsExpired)
  2.  Session schedule check (IsScheduleAllowed)
  3.  EOD Terminator (CheckForEODClose) → emergency close all positions
  4.  Daily P/L update and daily reset
  5.  Account Protection checks:
        → DailyLossReached?    → block new orders
        → DrawdownFreeze?      → block new orders
        → DailyTargetReached?  → block new orders
  6.  Equity Trailing Lock (master equity trailing SL)
  7.  Institutional Impulse Detection (CheckInstitutionalImpulse)
  8.  Dynamic Channel Update (UpdateDynamicChannel) every X hours
  9.  News Filter → freeze before/after news events
 10.  ManageAllPositions() → manage all open positions
 11.  Cooldown check + position count limit check
 12.  EvaluateStrategies() → Multi-Core Engine searches for a signal
 13.  Information panel update

All stages are independent — position management (step 10) runs regardless of whether new signals are being sought (step 12). Even when new orders are blocked, open positions are always managed.