YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

MT5 INTEL — Autonomous Cognitive Neural Trading Brain

A fully self‑contained MetaTrader 5 Expert Advisor that operates as a brain‑inspired, hybrid cognitive trading system. Every part of the intelligence — perception, memory, forecasting, reasoning, planning, risk, execution, self‑evaluation and continuous self‑improvement — runs entirely inside MQL5.

No Python · No DLLs · No external APIs · No cloud. 100% MQL5.

The system runs a closed cognitive loop on every cycle:

Observe → Understand → Predict → Plan → Execute → Monitor → Learn → Improve

Table of Contents


Highlights

  • Brain‑inspired 10‑layer architecture — sensory cortex, pattern cortex, temporal memory, neural forecasting, reasoning, strategic planning, risk intelligence, execution, self‑evaluation and meta‑learning.
  • Dual‑mode, manually selectable — high‑frequency Scalping (M1/M5) and Swing/Long, plus an automatic Hybrid that scalps small but holds runners for big moves. Works on any timeframe.
  • Full multi‑timeframe awareness — perceives a ladder of 4 timeframes at once so it understands the macro trend and avoids pullbacks / liquidity traps while scalping.
  • Ensemble intelligence — 8 independent experts (trend, momentum, mean‑reversion, breakout, volatility, liquidity, neural MLP, adaptive) fused by weighted consensus, Bayesian log‑odds and a Markov regime model. Never relies on a single model.
  • Genuine online learning — a trainable neural network, multiplicative‑weights ensemble adaptation, per‑regime Bayesian win priors and a meta‑learner that tunes thresholds, risk appetite and targets from realised outcomes.
  • Explainable by design — every decision logs its inputs, sub‑scores, confidence, expected value, macro bias, pullback risk and rationale. No black box.
  • Robust risk control — volatility position sizing, drawdown halt, exposure / risk‑budget caps, per‑trade leverage cap, break‑even and adaptive trailing.
  • Cross‑session memory — STM/MTM/LTM episodic memory, trade memory and learned weights persist to disk and reload on restart.
  • Built‑in validation — Monte‑Carlo, walk‑forward, stress and parameter‑stability tests run automatically on the live trade series.

Cognitive Architecture

Layer Module Responsibility
1 SensoryCortex Multi‑timeframe perception → 40‑dimensional Market State Tensor; macro trend; pullback risk; Kalman surprise
2 PatternCortex Detects trend/range/breakout/reversal/accumulation/distribution/liquidity‑sweep/compression; pattern sequence memory
3 TemporalMemory GRU recurrent context encoder + episodic k‑NN recall over long‑term memory
4 ForecastEngine 8‑expert ensemble + Markov regimes + Bayesian fusion → probabilistic direction / magnitude / risk / confidence
5 ReasoningEngine Evaluates probability, reward, risk, uncertainty, expected value → explainable decision
6 StrategicPlanner Builds the trade plan: entry, SL, TP, scaling, re‑entry, trailing, break‑even, emergency exit, runners
7 RiskIntelligence Drawdown tracking, exposure & risk‑budget control, volatility + leverage‑capped position sizing
8 ExecutionEngine Order entry/modification, break‑even, trailing, scaling, emergency exit; per‑position registry
9 SelfEvaluation Detects closed trades, computes R‑multiples, accuracy, decision quality and full performance metrics
10 MetaLearning Adapts caution, risk appetite and target multipliers; feature‑importance; prevents de‑risking lock‑up

Supporting engines (Include/MT5INTEL/Intelligence): trainable MLP + GRU (NeuralNet), KalmanFilter, BayesianEngine, MarkovModel, Ensemble. Memory (Memory/MemoryEngine) and Validation (Validation/Backtest, Validation/Validator). Everything is orchestrated by Brain.mqh.


Repository Structure

MQL5/
├─ Experts/
│  └─ MT5INTEL/
│     └─ MT5_INTEL.mq5            # the Expert Advisor (entry point)
├─ Include/
│  └─ MT5INTEL/
│     ├─ Brain.mqh               # cognitive orchestrator (owns all layers)
│     ├─ Core/                   # Config, Types, MathUtils, Logger
│     ├─ Intelligence/           # NeuralNet, Kalman, Bayesian, Markov, Ensemble
│     ├─ Memory/                 # MemoryEngine (STM/MTM/LTM, persistence)
│     ├─ Cognition/              # the 10 cognitive layers
│     └─ Validation/             # Backtest metrics + Validator battery
└─ Presets/
   └─ MT5INTEL_scalp_live.set    # ready‑to‑use scalping configuration
docs/
└─ ARCHITECTURE.md               # detailed design notes

Requirements

  • MetaTrader 5 (build 4000+ recommended; developed/tested on build 5836).
  • A symbol with sufficient history on your broker (developed on EURUSD).
  • No third‑party libraries, indicators or DLLs.

Installation

  1. Locate your terminal's data folder: in MetaTrader 5 → File → Open Data Folder.
  2. Copy the contents of this repository's MQL5/ folder into the terminal's MQL5/ folder, preserving the structure:
    • MQL5/Experts/MT5INTEL/MT5_INTEL.mq5
    • MQL5/Include/MT5INTEL/...
    • MQL5/Presets/MT5INTEL_scalp_live.set
  3. Open MetaEditor, open MT5_INTEL.mq5 and press Compile (F7). Expected result: 0 errors, 0 warnings.

Headless compile (Windows):

& "C:\Program Files\MetaTrader 5\MetaEditor64.exe" `
  /compile:"<DataFolder>\MQL5\Experts\MT5INTEL\MT5_INTEL.mq5" `
  /log:"<DataFolder>\MQL5\Experts\MT5INTEL\compile.log"
# Note: the log is UTF-16; check the "Result: N errors, M warnings" line.

Quick Start

  1. Open a chart for your symbol (for scalping, an M1 chart is ideal).
  2. Drag MT5_INTEL onto the chart.
  3. Enable Algo Trading in the toolbar and tick Allow Algo Trading in the dialog.
  4. (Optional) Load the preset MT5INTEL_scalp_live.set in the Inputs tab.
  5. The on‑chart HUD shows the live regime, forecast, decision, expert votes, account risk and learning statistics.

Always validate on a demo account and in the Strategy Tester before considering any live deployment. See the Risk Disclaimer.


Trading Modes

Set via the InpTradeMode input:

Mode Best for Behaviour
Scalping M1 / M5 High frequency, tight SL/TP, many small‑pip trades, break‑even fast, strict spread & pullback filters
Swing M15+ Fewer, larger trades on higher timeframes; may fade pullbacks; wider targets
Hybrid M5 Scalps small by default but converts strong, macro‑aligned setups into runners (wide TP + trailing) to hold for big moves

InpBaseTF selects the execution timeframe (or PERIOD_CURRENT = auto by mode). The EA always builds a 4‑rung timeframe ladder above the base so it keeps full macro context — for example scalping on M1 still watches M1 / M5 / M15 / H1.


Inputs Reference

Trading Mode

Input Default Description
InpTradeMode Scalping Scalping / Swing / Hybrid
InpBaseTF Current Execution timeframe (Current = auto by mode)

Risk Intelligence

Input Default Description
InpRiskPerTrade 0.01 Risk per trade (fraction of equity)
InpMaxRiskBudget 0.06 Max aggregate open‑risk fraction
InpMaxDrawdownStop 0.30 Halt new trades beyond this drawdown
InpMaxPositions 4 Max concurrent positions
InpMaxTradesPerDay 0 Daily entry cap (0 = unlimited)
InpMaxLeverage 3.0 Cap nominal exposure to N× equity per trade

Decision

Input Default Description
InpMinConfidence 0.52 Minimum confidence to act
InpMinEdge 0.02 Minimum expected‑value edge (R)
InpMaxSpreadATR 0.12 Scalp: skip when spread/ATR exceeds this

Behaviour

Input Default Description
InpAtrSLMult / InpAtrTPMult 1.8 / 2.6 Swing stop / target (ATR units)
InpScalpSLATR / InpScalpTPATR 0.9 / 1.1 Scalp stop / target (ATR units)
InpBeTriggerATR 0.6 Move SL to break‑even after this profit (ATR)
InpLetRunners / InpRunnerTPATR true / 4.0 Allow runners and their wide target
InpAllowTrading true Master execution switch
InpOnBarOnly true Decide once per exec‑TF bar (false = every tick)

Learning & System

Input Default Description
InpLearnRate / InpMetaLearnRate 0.02 / 0.05 Neural / ensemble learning rates
InpValidateEvery 20 Run the validation battery every N closed trades
InpMagic 20260623 Magic number
InpPersist true Persist learning across sessions
InpVerbose false Verbose logging
InpTimerSeconds 5 Management timer interval (seconds)

How It Works

On each decision cycle the brain:

  1. Observes the market across four timeframes and builds a normalised Market State Tensor (returns, momentum, trend, volatility, structure, liquidity, range position, plus macro trend, multi‑timeframe alignment and pullback risk).
  2. Understands the state — classifies the regime (softmax posterior + entropy), detects the dominant pattern and updates recurrent + episodic memory.
  3. Predicts direction, magnitude, volatility, risk and confidence via the ensemble.
  4. Reasons about probability, reward, risk, uncertainty and expected value, applying the macro‑trend and pullback guards, then emits an explainable decision.
  5. Plans a complete trade (entry, SL, TP, sizing, scaling, break‑even, trailing, emergency exit; runner vs. quick‑scalp).
  6. Executes and monitors the position with trailing, break‑even and scaling.
  7. Learns from every closed trade — trains the network, adapts ensemble weights and Bayesian priors, and the meta‑learner tunes caution, risk appetite and targets.

Every entry is logged with its full rationale, e.g.:

SELL | P(up)=0.34 edge=0.31 conf=0.50 EV=0.51R pWin=0.68 risk=0.45 unc=0.59 |
macro=-0.91 pull=0.18 spr/atr=0.00 | regime=1(0.63) pat=1(str0.69) |
trend=-1.00 mom=-0.23 mr=0.62 neural=-0.15 | mode=SCALP caution=1.00 -> SELL

Persistence & Continuous Learning

When InpPersist is enabled, the brain saves its full state — adaptive normalisation, GRU/MLP/Markov/Bayesian/ensemble weights, STM/MTM/LTM memory, trade memory and meta‑learning parameters — to MQL5/Files/MT5INTEL/<symbol>_<magic>.intel and reloads it on restart, so it keeps improving across sessions.


Validation & Backtesting

A validation battery runs automatically every InpValidateEvery closed trades and logs:

  • Monte‑Carlo bootstrap (final‑equity percentiles, max‑drawdown, probability of profit / ruin),
  • Walk‑forward consistency across segments,
  • Stress test (spread/slippage haircut + loss amplification),
  • Parameter‑stability (jackknife), and
  • a per‑regime breakdown.

OnTester() returns a robustness‑weighted objective for Strategy‑Tester optimisation.


Verified Results

Built and tested with MetaTrader 5 (MetaEditor build 5836) on EURUSD. Compiles with 0 errors / 0 warnings. Representative Strategy‑Tester runs (1‑minute model, persistence off, generic untuned parameters):

Scenario Trades Notes
Scalping, M1, $100k, 3 months 2027 0 runtime failures; max lot 1.99 (2× leverage cap); +0.27%
Hybrid, M5, 7 months 97 58 runner trades; 0 failures
Swing, M15, 12 months 5 +0.31%; conservative by design

The EA was also verified live on a demo account (real‑time ticks): it connected, attached to an M1 chart, perceived live data and executed trades with full, explainable rationale.

Honesty note. With generic, untuned parameters the strategy is roughly break‑even — the goal of this project is the cognitive architecture, dual‑mode high‑frequency engine, multi‑timeframe awareness, risk control and online learning, not a pre‑optimised money printer. Sustained profitability requires per‑symbol/per‑broker tuning via the built‑in walk‑forward tooling and OnTester() optimisation. Past performance does not guarantee future results.


Risk Disclaimer

This software is provided for research and educational purposes. Trading foreign exchange, CFDs and other leveraged instruments carries a high level of risk and may not be suitable for all investors. You can lose some or all of your capital. Always test on a demo account first. Nothing in this repository constitutes financial advice. You are solely responsible for any use of this software and any resulting trades. The authors accept no liability for any losses incurred.


Roadmap

  • Per‑symbol parameter optimisation profiles.
  • Portfolio mode (multi‑symbol shared risk budget).
  • Optional news / session filters.
  • Extended pattern library and additional ensemble experts.

License

Proprietary. See LICENSE. © 2026 root975638‑alt. All rights reserved.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support