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.

Institutional Impulse + Muzzle Mode

5. Institutional Impulse + Muzzle Mode

One of the defining mechanisms of the system. It detects institutional impulses (sudden, violent moves generated by large capital) and immediately changes the system’s behaviour.

Impulse Detection

On every new bar on Inp_Impulse_TF (default M1):

  1. Calculates average range and average volume over the last Inp_Impulse_AvgPeriod (20) candles
  2. Fetches ATR
  3. Calculates velocity = |current_close - prev_close| / prev_close
  4. Impulse detected if candle range > Inp_Impulse_Min_Range_Points (50 pts) AND at least ONE of the following is true:
  • velocity > Inp_Impulse_Velocity (0.5% price change)
  • current_range > RangeMult × avg_range (2× average)
  • current_range > ATRMult × ATR (2× ATR)
  • current_volume > VolMult × avg_volume (1.5× average volume)

Log: "Institutional Impulse Detected! Activating MUZZLE MODE for 15 mins."

Muzzle Mode — How the System’s Characteristics Change

After an impulse is detected, the system enters Muzzle Mode:

ParameterNormal ModeDuring Impulse (Muzzle Mode)
Min. Smart DI candle body2 pts150 pts
CCI block levelInp_Block_CCI_Level (350)Inp_Muzzle_CCI_Block_Level (130)
SELL signalsAllowedBlocked if Channel_Down = 0
Price channelStandard Dynamic ChannelMuzzle Box (anchored at impulse price)

Key point: When Inp_Muzzle_Channel_Points_Down = 0, the system operates exclusively as BUY ONLY during an impulse — selling is completely blocked. This allows the system to ride the momentum after a breakout move.

Dynamic Muzzle Channel

At the moment an impulse is detected, the system saves the current BID price (g_Muzzle_BasePrice). All subsequent signals must fall within:

  • Upper: base_price + Muzzle_Channel_Points_Up
  • Lower: base_price - Muzzle_Channel_Points_Down (or -DBL_MAX when Down = 0)

Muzzle Mode Deactivation

Muzzle Mode expires only when ALL of the following conditions are met:

  1. Cooldown elapsed: (current_time - impulse_time) > Impulse_Cooldown_Mins × 60
  2. Market has calmed: current_range ≤ 1.5 × avg_range AND current_volume ≤ 1.5 × avg_vol
  3. A local peak or trough has formed: the previous candle has a higher high (peak) or lower low (trough) than its neighbours

Log: "Market calmed down. MUZZLE MODE deactivated."

Makro Matrix Risk — dynamiczna punktacja instytucjonalna

4. Makro Matrix Risk — dynamiczna punktacja instytucjonalna

This is the most unique feature of the system. Before every order, AHS consults 19 global assets, analysing each through 5 indicators — a total of 95 indicator handles running in parallel.

Skład Makro Matrix Risk

Tech Titans (≈60% of the pool):

AssetBase Weight
Apple (AAPL)8%
Microsoft (MSFT)8%
Nvidia (NVDA)8%
Amazon (AMZN)5%
Meta (META)5%
Alphabet (GOOGL)5%
Tesla (TSLA)4%
Broadcom (AVGO)4%
Costco (COST)3%
Netflix (NFLX)2%
PepsiCo (PEP)2%
Cisco (CSCO)2%
T-Mobile (TMUS)2%
Adobe (ADBE)1%
AMD1%

Global Macro (≈40% of the pool):

AssetBase WeightSpecial Role
Bitcoin (BTC)10%Risk-On barometer
Gold (GOLD)10%Inverse correlation — Risk-Off
EURUSD10%Dollar strength proxy (DXY)
AUDJPY10%Carry trade / risk appetite

Dynamic Weighting — What Sets This System Apart

Base weights are a starting point, not fixed values. For each asset, a multiplier is computed based on current indicators:

Indicators per asset (H1 timeframe):
  → MA50, MA200   (long-term trend)
  → RSI(14)       (momentum / overbought-oversold)
  → CCI(14)       (deviation from mean)
  → MFI(14)       (money flow)

Multiplier logic for BUY scoring:
  → Bullish trend (MA50 > MA200):          +0.5
  → Oversold (RSI<30 or CCI<-100):        +0.5
  → Overbought (RSI>70 or CCI>100):       -0.5
  → Money flowing in (MFI>50):            +0.2

Multiplier logic for SELL scoring:
  → Bearish trend (MA50 < MA200):          +0.5
  → Overbought (RSI>70 or CCI>100):       +0.5
  → Oversold (RSI<30 or CCI<-100):        -0.5
  → Money flowing out (MFI<50):           +0.2

Minimum multiplier = 0.1 (prevents negative weights).

Scoring Mechanism

effective_weight = base_weight × multiplier
max_pool        += effective_weight           // maximum possible score

// Does this asset confirm the direction?
if BUY:  price > MA50 → align_score += effective_weight
if SELL: price < MA50 → align_score += effective_weight

// GOLD is inverse (is_inverse=true):
// Bullish GOLD = Risk-Off = confirms SELL, not BUY

final_alignment = (align_score / max_pool) × 100%

Block condition: If final_alignment < Inp_Macro_Min_Alignment_Percent (default 70%) → order blocked.

Lazy Evaluation

The Macro Matrix is not computed on every tick. It is triggered exclusively when a strategy generates a signal. This dramatically reduces CPU usage. Log: "BUY Align: 82% (Pool: 145)" / "Block BUY: Macro Score".

When No Market Is Active

When all assets are inactive (no data, markets closed) → max_pool = 0 → filter bypassed, trading allowed. The system never blocks itself when global data is unavailable.

Strategies — Detailed Algorithm Descriptions

3. Strategies — Detailed Algorithm Descriptions

3.1 Smart DI (Directional Index)

Concept: Measures the dominance of one market direction using the ADX indicator, analysing the difference between the DI+ and DI- lines.

Algorithm — step by step:

  1. Fetches DI+ and DI- values from ADX (buffer 1 — the previous closed bar, to avoid repainting)
  2. Calculates diff = |DI+ - DI-|
  3. Fetches data for the last closed candle on Inp_Strat_TF
  4. Calculates candle body size: body = |close - open| / _Point
  5. If Impulse/Muzzle Mode is active: the minimum candle body requirement rises from Inp_Strat_Min_Candle_Body to Inp_Muzzle_Min_Candle_Body (default 150 pts instead of 2 pts) — the strategy’s characteristics change during an impulse
  6. BUY signal: DI+ > DI- AND diff > Min_DI_Diff AND DI- < Max_Opposite_DI
  7. SELL signal: DI- > DI+ AND diff > Min_DI_Diff AND DI+ < Max_Opposite_DI

Log: "Smart DI BUY" / "Smart DI SELL"

Key property: The Inp_Strat_Max_Opposite_DI parameter limits opposition strength — even when DI+ dominates, an overly strong DI- blocks the signal. It acts as a built-in trend quality filter.

3.2 MTF Point System (Multi-TimeFrame)

Concept: Scores trend alignment across 4 independent timeframes using EMA5/EMA7 crossovers. Each timeframe earns one point; a minimum score threshold is required.

Algorithm — step by step:

  1. On each of the 4 timeframes (TF1, TF2, TF3, TF4), fetches EMA5 and EMA7
  2. BUY point: EMA5 > EMA7 on that TF → score++
  3. SELL point: EMA5 < EMA7 on that TF → score++
  4. If score >= Inp_MTF_Min_Score (default 3 out of 4) → signal is active

Check condition: On every new bar of Inp_MTF_TF1 (the fastest TF)

Log: "MTF BUY" / "MTF SELL"

Philosophy: The system does not require perfect alignment — even 3 out of 4 timeframes is sufficient. This provides flexibility in fluid markets where all timeframes rarely agree simultaneously.

3.3 Three Consecutive Candles

Concept: Detects a mini-trend: 3 consecutive closed candles in the same direction with a minimum body size.

Algorithm — step by step:

  1. Fetches the last 3 closed candles on Inp_Filter_3Candles_TF
  2. For each candle: body = |close - open| / _Point
  3. If any candle’s body < Inp_Filter_3Candles_MinBody → signal is invalid
  4. BUY: all 3 candles are bullish (close > open)
  5. SELL: all 3 candles are bearish (close < open)

Log: "3 Candles BUY" / "3 Candles SELL"

Strength: Simple, visually intuitive, and highly effective as a validator — it confirms momentum before Smart DI or MTF fire their signals.

Multi-Core Strategy Engine — „First Come, First Served”

2. Multi-Core Strategy Engine — „First Come, First Served”

This is the system’s most important architectural innovation. Despite the name suggesting a single strategy, AHS is a strategy engine with interchangeable cores, where each strategy can simultaneously fulfil two roles:

RoleParameterDescription
Trigger_As_Strategy = trueThe strategy GENERATES the trade signal
Validator_As_Filter = trueThe strategy CONFIRMS signals from other strategies

The „First Come, First Served” Rule

Strategies are evaluated sequentially in a fixed order:

EvaluateStrategies()
  1. Smart DI (if As_Strategy=true)       → signal? → filters → order → RETURN
  2. MTF Point System (if As_Strategy=true) → signal? → filters → order → RETURN
  3. 3 Consecutive Candles (if As_Strategy=true) → signal? → filters → order → RETURN

Critical implication: When strategy #1 (Smart DI) generates a valid signal and passes all filters, the system immediately opens an order and exits the function (return). Strategies 2 and 3 are never evaluated on that tick. There is no voting, averaging or consensus — the first valid signal wins.

Each strategy is checked only once per new bar (on its own timeframe), which eliminates multiple signals within the same candle.

Configuration Possibilities

  • SmartDI as trigger, MTF + 3Candles as filters — SmartDI fires the signal, but it must be confirmed by both other systems
  • All three as triggers — three independent strategies compete to open a trade
  • MTF as trigger, SmartDI as filter — MTF generates, SmartDI confirms
  • Any combination — each strategy can be independently enabled/disabled in either role

A Validator Does Not Validate Itself

Smart logic: strategy X acting as a filter does NOT validate its own signals. Example: if SmartDI is the trigger, the SmartDI filter is skipped (it does not check itself) — only MTF and 3Candles filters are checked.

// Validator skips its own source
if (Inp_SmartDI_As_Filter && trigger_source != "SmartDI") {
    if (!CheckSmartDI_Condition(is_buy)) return false;
}

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.

Full Technical Documentation

AHS — Adaptive Hybrid System v78.00

Full Technical Documentation

Multi-Core Strategy Engine for MetaTrader 5 (MQL5)

Project built from July 10th, 12+ hours a day, often seven days a week — through April 21st.


TABLE OF CONTENTS

  1. Architecture & Module Connections
  2. Multi-Core Strategy Engine — “First Come, First Served”
  3. Strategies — Detailed Algorithm Descriptions
  4. Macro Risk Matrix — Dynamic Institutional Scoring
  5. Institutional Impulse + Muzzle Mode — Behavior Change During Impulse
  6. Dynamic Channel (Box Trading) — Price Tunnel
  7. Position Management — Protection Layers
  8. Account Protection — System Level
  9. Manual Trade Management (Click & Forget)
  10. Trading Schedule & EOD Terminator
  11. News Filter
  12. Weekly Filter & Fibonacci (Anti-Crash)
  13. Capital Management & Position Sizing
  14. Pyramiding (Position Scaling)
  15. Information Panel
  16. License & Updates
  17. Full Input Parameter Reference

1:500

Adaptive Hybrid System - Multi-Core Strategy Engine -US100
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.