Skip to main content

An AI-powered trading assistant for MetaTrader 5.

Project description

MetaTrader AI

An AI-powered trading assistant for MetaTrader 4 and MetaTrader 5! Now you can use AI in your trading strategies.

Features

Feature Python MQL
Open, close, modify positions & orders
Modify SL, TP, and entry prices
Fetch positions, orders, and deal history
Account info (balance, equity, margin, etc.)
Symbol info (bid, ask, spread, digits, lots)
OHLCV bars and individual bar prices
Pip value and risk-based lot sizing
MQL5 file compilation
20+ technical indicators (MA, RSI, ATR, ADX, MACD, Stochastic, CCI, WPR, Momentum, Envelopes, Fractals, Bulls/Bears Power, VWAP, PVI, AO, ADR, ATHR, custom)
Chart screenshots and analysis
Open, close, and inspect charts
Enable/disable symbols in Market Watch
Terminal info (OS, CPU, memory, build, connection)
File operations (read, write, copy, move, delete)
Chat GUI (desktop or on-chart panel) ✅ Desktop ✅ On-chart

Requirements

  • Windows operating system (for Python integration, MQL works on all platforms that MetaTrader supports)
  • MetaTrader 5 and Python 3.9.7 or higher for Python integration
  • MetaTrader 4 or MetaTrader 5 for MQL integration
  • OpenAI or DeepSeek API key

Installation

Python

pip install metatrader-ai

MQL

  1. Navigate to MetaTrader's data folder (File → Open Data Folder), then:
cd "C:\Users\YourUsername\AppData\Roaming\MetaQuotes\Terminal\YourTerminalID"
cd MQL4 # or MQL5
cd Include
  1. Clone the repo into the Includes folder:
git clone https://github.com/jblanked/metatrader-ai.git

Usage

Desktop GUI (Python)

from metatrader_ai.app import launch
from metatrader_ai.llm import DEEPSEEK  # or OPENAI

launch(
    api_key="...",
    account_login=...,
    account_password="...",
    broker_server_name="...",
    model=DEEPSEEK,  # default; use OPENAI for OpenAI
)

Or pass a pre-built agent:

from metatrader_ai.app import launch
from metatrader_ai.agent import Agent

agent = Agent(
    api_key="...",
    account_login=...,
    account_password="...",
    broker_server_name="...",
)
launch(agent=agent)

Without an agent (info-only mode):

from metatrader_ai.app import launch
launch()

The Chat tab lets you converse with the AI assistant about your positions, market analysis, and trading strategies. The Info tab displays terminal, symbol, and account details from MetaTrader 5.

One-shot Function

from metatrader_ai.agent import run

result = run(
      api_key=API_KEY,
      account_login=ACCOUNT_LOGIN,
      account_password=ACCOUNT_PASS,
      broker_server_name=BROKER_NAME,
      prompt="What is the daily high of ETHUSD?",
)

Multi-turn Class API

from metatrader_ai.agent import Agent

agent = Agent(
    api_key="...",
    account_login=...,
    account_password="...",
    broker_server_name="...",
)
response = agent.run("What is the daily high of ETHUSD?")
print(response)

Command Line

metatrader-ai \
   --api-key "$DEEPSEEK_API_KEY" \
   --account-login "$ACCOUNT_LOGIN" \
   --account-pass "$ACCOUNT_PASS" \
   --broker-name "$BROKER_NAME" \
   --provider deepseek

Use --provider openai (with OPENAI_API_KEY) to switch to OpenAI.

Single prompt mode:

metatrader-ai --prompt "Show account info" ...

MQL (In-Editor)

#include <metatrader-ai/mql/agent.mqh>

void OnStart()
{
   Agent *agent = new Agent(
      "your-api-key",               // API key
      LLM_PROVIDER_DEEPSEEK,        // provider (default)
      DEEPSEEK_MODEL_V4_FLASH       // model (default)
   );
   string response = agent.run("What is the daily high of ETHUSD?");
   Print("[Agent] ", response);
   delete agent;
}

Use LLM_PROVIDER_OPENAI with an OpenAI model (e.g. OPENAI_MODEL_GPT_5_4_MINI) to switch providers.

Or compile and run app.mq5 (in metatrader-ai/mql) to get an on-chart chat panel with provider/model inputs where you can type prompts and see AI responses.

Notes

  • I am available for hire to integrate your strategy into the system, with advanced prompts and multi layer thinking: https://www.jblanked.com/coding-request/
  • In the Python environment, two LLM providers are supported: DeepSeek (deepseek-v4-flash, default) and OpenAI (gpt-5.4-mini). Switch with --provider in the CLI or model=OPENAI / model=DEEPSEEK (from metatrader_ai.llm) in code. In MQL, switch providers and models with the providerId and providerModel parameters when creating the Agent (e.g. LLM_PROVIDER_OPENAI with OPENAI_MODEL_GPT_5_4_MINI).
  • The python environment works best directly inside of MetaTrader5, but if you run it from a Windows terminal, you should open up MetaTrader5 and log in to your account first, then run the python script for the best experience. The script attempts to open and login to MetaTrader5 if it is not already open.

Disclaimer

Trading and investing involve substantial risk. Past performance is not indicative of future results. This software is provided for educational and informational purposes only and should not be considered as financial advice. Always do your own research and consult with a qualified financial advisor before making any trading decisions. JBlanked and the developers of this software are not responsible for any losses or damages that may occur from using this software.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metatrader_ai-1.2.2.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metatrader_ai-1.2.2-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file metatrader_ai-1.2.2.tar.gz.

File metadata

  • Download URL: metatrader_ai-1.2.2.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for metatrader_ai-1.2.2.tar.gz
Algorithm Hash digest
SHA256 bb9410b1d6652b329a112cf1c2e3221e9796c68a31a1ae30dc24a4e62a73a138
MD5 933c97d3d0f921aa0e4454f866bf754c
BLAKE2b-256 b4af9689bbccb84839ec8f72f3918f135748d2800a1e5756c4e3722a9614dcd4

See more details on using hashes here.

File details

Details for the file metatrader_ai-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: metatrader_ai-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for metatrader_ai-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d40fe9019ae9f60c9534d78edda14afd8235af85384b9cd04c5efb5cc692408
MD5 b3cf801946f58a53ea60d09944bdabac
BLAKE2b-256 04ef3384e7ec1a4904cd45ce5752d397c05588a7e1cc43be79cb6b52889f8b9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page