Trading robot · MT5

Cortex5 AI Trading

by toniibrahim

This artificial intelligence expert advisor for MetaTrader 5 utilizes a Double-Dueling Deep Recurrent Q-Network with LSTM memory to automate forex trading.

High risk

GitHub stars2
Forks0
Last update1 year ago20 Aug 2025
LicenceNone stated

Overview

The system processes a 45-dimensional state space to execute trades based on reinforcement learning. It includes extensive risk management features such as ATR-based dynamic stop losses, take profit targets, and a maximum holding time of 72 hours. To prevent overtrading, it employs a sophisticated cooldown system and choppy market detection. The EA requires a separate pre-trained model file to operate.

Details

Author

toniibrahim on GitHub

Type

Trading robot

Platform

MetaTrader 5 (MQL5)

Strategy

AI / machine learning, Martingale

Markets

Forex

Timeframes

M15-H1, H4 and above

Risk profile

  • Uses martingale lot scaling: losses can grow fast

EA files

Input parameters

Read from cortex5.mq5. Defaults are the author's; change them in the EA's Inputs tab.

NameTypeDefaultDescription
InpModelFileNamestringDoubleDueling_DRQN_Model.datAI brain file (must be trained first)
InpRiskPercentdouble5.0Risk per trade as % of total account balance
InpMaxSpreaddouble15.0Don't trade if broker spread exceeds this (points)
InpATRMultiplierdouble2.0Stop loss distance as multiple of Average True Range
InpRRRatiodouble1.5Risk:Reward ratio (1.5 = target 1.5x profit vs loss)
InpMaxDrawdowndouble10.0Pause trading if account loses more than this %
InpMinWinRateint30Pause if win rate drops below this % (over last 10 trades)
InpCommissionPerLotdouble0.0Your broker's commission per lot (for accurate cost calculation)
InpUseRiskSizingbooltrueUse smart position sizing based on volatility
InpEnforceSymbolTFbooltrueOnly trade the symbol/timeframe the model was trained on
InpAllowPositionScalingbooltrueAllow adjusting position size based on signal strength
InpMaxHoldingHoursint72Maximum hours to hold a position (Phase 1)
Show all 40 inputs
NameTypeDefaultDescription
InpProfitTargetATRdouble2.5Take profit at N x ATR (Phase 1)
InpUseProfitTargetsbooltrueEnable automatic profit taking (Phase 1)
InpUseMaxHoldingTimebooltrueEnable maximum holding time control (Phase 1)
InpHoldingTimePenaltydouble0.001Penalty per hour held in reward calculation (Phase 1)
InpQuickExitBonusdouble0.005Bonus for trades < 24 hours (Phase 1)
InpFlatActionWeightdouble1.5Increased weight for FLAT action in future training (Phase 2)
InpEnhancedRewardsbooltrueUse enhanced reward calculation (Phase 2)
InpDrawdownPenaltydouble0.01Penalty for unrealized drawdown (Phase 2)
InpUseDynamicStopsbooltrueEnable dynamic stop loss tightening (Phase 3)
InpStopTightenRatedouble0.8Stop tightening multiplier per day held (Phase 3)
InpUsePositionFeaturesbooltrueAdd position-aware features to state (Phase 3)
InpUseMarketRegimebooltrueEnable market regime detection (Phase 3)
InpMinBarsBetweenTradesint4Minimum bars between trades
InpMaxTradesPerDayint8Maximum trades per day
InpEnforceFlatbooltrueForce FLAT when position reaches limits
InpUseAdvancedCooldownbooltrueEnable enhanced cooldown system
InpMinCooldownMinutesint65Minimum cooldown period after closing position (minutes)
InpUseChoppyDetectionbooltrueEnable choppy market detection
InpChoppyATRThresholddouble0.8ATR ratio threshold for choppy markets (current vs 20-period avg)
InpChoppyLookbackPeriodint20Lookback period for choppy market analysis
InpChoppyMinRangeint30Minimum points range to avoid micro-movements
InpUseConsecutiveLossesbooltrueEnable consecutive loss protection
InpMaxConsecutiveLossesint3Max consecutive losses before extended cooldown
InpExtendedCooldownMinint120Extended cooldown after consecutive losses (minutes)
InpUseLossBasedCooldownbooltrueScale cooldown based on loss size
InpUseSignalRefinementbooltrueEnable enhanced signal processing
InpUseSignalSmoothingbooltrueEnable signal smoothing over multiple bars
InpSignalSmoothingPeriodint3Number of bars for signal averaging

How to install it

  1. 1Download the sourceUse "Download source (.zip)" above, or clone toniibrahim/cortex5-ai-trading from GitHub, and unzip it.
  2. 2Open the data folderIn MetaTrader choose File, then Open Data Folder, and go to MQL5/Experts.
  3. 3Copy the filesCopy the .mq5 file into Experts, and any .mqh files into the Include folder the code expects.
  4. 4Compile in MetaEditorOpen the file in MetaEditor and press Compile. Fix any missing includes the compiler reports.
  5. 5Test before you tradeRun it in the Strategy Tester, then attach it to a demo chart and allow algorithmic trading.
Third-party code. ForexR did not write, test or endorse this EA, and the summary above was generated automatically from its README and code. ForexR lists only repositories with readable source code and never hosts files. Read the code, backtest it and use a demo account first; automated trading can lose money quickly.

Similar expert advisors

AI Enhanced HFT

by Marco210210
20 stars

This MetaTrader 5 expert advisor combines technical indicators with machine learning forecasts to trade the Forex market. It uses a trend-following approach based on Exponential Moving Average crossovers, filtered by the Average Directional Index and volume confirmations. A unique feature is its integration with extern

MT5 Trading robot Trend followingIndicator crossoverAI / machine learning High risk
Updated 1 year ago None stated GitHub repository of AI Enhanced HFT
4 stars

This machine learning robot for MetaTrader 5 uses an ensemble of AI models including LSTM, GRU, and LightGBM to predict price movements. It executes trades based on signal confidence and predicted price targets. The EA features multiple risk controls such as volatility filters, trend-based MA filters, RSI checks, and a

MT5 Trading robot AI / machine learningTrend followingMartingale High risk
Updated 4 months ago GPL-3.0 GitHub repository of GGTH Forex Predictor
2 stars

This MetaTrader 5 expert advisor utilizes an Echo State Network, which is a type of recurrent neural network, to analyze price action and execute trades. The system computes various statistical inputs, including price volatility, mean values, and Hurst exponent metrics, to feed its reservoir computing model. Risk is ma

MT5 Trading robot AI / machine learningMartingale High risk
Updated 2 years ago None stated GitHub repository of Echo State Network Tester

Saxby Andrew ML EA

by saxbyandrew
2 stars

This MetaTrader 5 expert advisor is a legacy project focused on machine learning and neural network forecasting. The system implements logic for training models and generating forecasts using technical indicators like ADX and ZigZag. It includes several optional modules for long, short, hedging, and martingale trading

MT5 Trading robot AI / machine learningMartingaleHedging High risk
Updated 5 years ago None stated GitHub repository of Saxby Andrew ML EA
1 stars

LQS AI Institutional Engine is a MetaTrader 5 robot designed for trading gold using market microstructure analysis. It combines four analytical modules focusing on liquidity sweeps, order flow divergence, Wyckoff accumulation and distribution phases, and multiple anchored VWAP levels. The system features an integrated

MT5 Trading robot SMC / ICT / price actionAI / machine learningMean reversion High risk
Updated 4 months ago None stated GitHub repository of Lqs Ai Institutional Engine
1 stars

This machine learning expert advisor for MetaTrader 5 utilizes ensemble and deep learning models to analyze market patterns. It offers a versatile multi-strategy approach, allowing users to toggle between trend-following, scalping, and grid-hedging behaviors. Risk controls are comprehensive, featuring fixed percentage

MT5 Trading robot AI / machine learningMulti-strategyScalping High risk

More trading robots

Need a broker for MT5?

Compare regulated brokers that support MetaTrader, with spreads, minimum deposits and leverage side by side.

Compare brokers