Trading Schedule & EOD Terminator

10. Trading Schedule & EOD Terminator

Session Schedule (Terminal Local Time)

Each weekday has its own trading window:

Monday:    Inp_Hours_Monday    = "00:00-22:00"
Tuesday:   Inp_Hours_Tuesday   = "00:00-22:00"
Wednesday: Inp_Hours_Wednesday = "00:00-22:00"
Thursday:  Inp_Hours_Thursday  = "00:00-22:00"
Friday:    Inp_Hours_Friday    = "00:00-05:00"  // earlier close — weekend risk

Format: "HH:MM-HH:MM" — multiple ranges per day can be entered, comma-separated, e.g. "09:00-12:00,15:00-20:00". Saturday and Sunday are automatically blocked.

EOD Terminator

An emergency mechanism for closing all positions at a defined time:

Friday:     Inp_EOD_Time_Friday    = "21:39"
Other days: Inp_EOD_Time_OtherDays = "22:29"

Algorithm with retry logic:

  1. Attempts to close all positions on the symbol
  2. If the broker rejects an order → waits 5 seconds → retries (up to 10 attempts)
  3. On success: g_Last_EOD_Day = dt.day_of_year (does not repeat on the same day)

Log: "EOD TERMINATOR: Emergency closing all positions..." → "EOD SUCCESS: Closed position #123." → "EOD TERMINATOR: Chart cleared. Goodnight."

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.