MT5 Multi Regime & ML Forex Trading Bot

    by Sini Salu

    1

    A production-structured MetaTrader 5 trading framework with ML regime filtering and automated risk management.

    $100

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    MT5 Multi Regime & ML Forex Trading Bot

    Example session with this skill installed

    Set up the MT5 Forex trading bot for EURUSD and XAUUSD on my demo account. Configure a 1% max risk per trade, a 4% daily drawdown limit, retrain the offline ML model on recent historical data, and verify the configuration before launching the bot.

    • Read your context and instructions
    • Compiled the mt5 multi regime
    • Generated the data export

    I have configured your

    MT5 Multi-Regime & ML Forex Trading Bot for EURUSD and XAUUSD, retrained the regime classifier, and verified all risk guardrails before execution.

    1. Configuration & Risk Parameters Applied (config.py)

    Environment variables were mapped so your broker credentials stay out of plain text, and risk_manager.py limits have been locked in:

    ParameterConfigured ValueModule Enforced
    Account ModeDemo (MT5_SERVER verified)mt5_connection.py
    Active SymbolsEURUSD, XAUUSDconfig.py
    Risk Per Trade1.0% of account balancerisk_manager.py
    Max Daily Drawdown4.0% hard equity stoprisk_manager.py
    Trailing StopEnabled (1.5x ATR step)risk_manager.py
    Min Risk-to-Reward1 : 2.0signal_engine.py

    2. Offline ML Model Calibration (train_offline.py)

    Executed python train_offline.py --symbols EURUSD XAUUSD against historical MT5 candle data:

    • Training Window: 24 months of M15/H1 OHLCV & indicator features (indicators.py, patterns.py)
    • Regime Detection: Trending, Ranging, and High-Volatility states classified and serialized for ml_model.py
    • Validation Check: Out-of-sample precision filter active (confidence_threshold = 0.65)

    3. Pre-Flight Verification & Launch

    
    # 1. Verified MT5 terminal IPC bridge
    python -c "import mt5_connection; mt5_connection.test_connection()"
    
    # Output: [OK] Connected to MetaTrader 5 Demo Server | Balance: $10,000.00
    
    # 2. Launch automated execution loop with structured logging
    python main_bot.py --mode demo --log-file logs/session_01.csv
    

    Next Steps

    • Monitor live signal evaluations and order routing in <code>logs/session_01.csv</code> via <code>trade_logger.py</code>.
    • Let the bot run on your demo account across at least 30–50 sample trades before reviewing win-rate metrics or adjusting indicator periods in <code>config.py</code>.

    session_01.csv

    CSV · data export

    Generated

    Example file from a real run - the skill writes it into your workspace.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Setting up an automated trading system often results in fragmented scripts and loose risk controls that lead to account blowouts. This skill provides a production-ready Python framework for MetaTrader 5 that integrates price action, technical indicators, and machine learning into a unified execution engine.

    What it does

    • ML Regime Filtering uses offline training to classify market environments and filter out low-probability signals.
    • Price Action Detection scans for multi-candle patterns and market structure shifts in real-time.
    • Automated MT5 Execution handles the complete lifecycle of authentication, data polling, and order routing.
    • Strict Risk Management enforces position sizing, trailing stop-losses, and hard caps on daily drawdown.
    • Audit Logging records every signal score and execution detail for post-trade performance analysis.

    How it works

    1. Initialize Environment: Install dependencies and verify the Windows-based MT5 terminal connection.
    2. Configure Security: Set account credentials via environment variables to keep sensitive data out of config.py.
    3. Calibrate Models: Run the offline training script to generate weights for specific currency pairs.
    4. Deploy Bot: Launch the primary execution loop to monitor watchlists and manage active positions.

    Frameworks & tools

    This system is built with Python 3.10+ and the MetaTrader5 library. It requires a Windows environment to interface with the MT5 Desktop Terminal.

    Why this beats prompting it yourself

    Building a reliable trading loop requires complex state management and error handling for broker connections. This skill provides a pre-structured architecture where risk management and signal logic are decoupled, preventing the common bugs found in monolithic AI-generated scripts.

    Use cases

    • Deploy a trend-following bot on a MetaTrader 5 demo account for forward testing.
    • Backtest and train a machine learning model on historical OHLCV data.
    • Automate position sizing based on a fixed percentage of current account equity.
    • Audit existing trading logs to correlate ML signal scores with actual PnL.

    Known limitations

    Requires Windows OS for the MetaTrader5 Python package. Users must manually install and log into the MT5 Desktop Terminal before execution.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 11 days ago

    Software
    Python

    Install Python dependencies via pip install -r requirements.txt and ensure "Algo Trading" is enabled in your MetaTrader 5 terminal toolbar before running main_bot.py. Always test on a Demo account first.

    Permissions

    Terminal / Shell
    Listed11 days ago

    What's inside

    Frequently Asked Questions

    This skill provides a production-ready Python framework that bridges machine learning with MT5. It solves the issue of inconsistent execution by decoupling signal logic from risk management, ensuring that every trade is filtered through ML regime detection and strict drawdown controls.

    The framework is built for Python 3.10+ and requires a Windows environment to interface with the MetaTrader 5 Desktop Terminal. It is designed to work as a standalone execution engine or can be integrated into broader AI-driven trading workflows that support Python script execution.

    You will receive the complete modular Python architecture, including the core execution engine, ML training scripts, risk management modules, and a template for environment-based security configuration. Documentation for installation and model calibration is also included.

    No, this skill is designed to be broker-agnostic. As long as your broker supports the MetaTrader 5 Desktop Terminal and provides a Python API connection, you can use this framework to automate your trading.

    The framework uses a 'Security-First' approach where account credentials and API keys are stored in environment variables. This prevents sensitive information from being hardcoded in your configuration files, protecting your account even if you share your script structure.

    Yes, the skill is designed for modularity. While it comes with pre-configured price action and technical indicators, the architecture allows you to plug in your own logic or adjust the ML training parameters to suit different currency pairs and trading styles.

    New in Trading & Investing

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Trading & Investing.