MetaTrader 4/5 Skill for K.I.T.

SkillCommerce & finance

About AI quantitative trading platform for crypto, stocks, and forex with backtesting, live trading, market data, and multi-agent research.vibe-trading ,trading-agents,ai-trader,ai-trading

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the MetaTrader 4/5 Skill for K.I.T. skill

What this skill tells your AI

The instructions your AI receives, as published by signal-execution-labs/forex-trading-ai-agent in skills/metatrader/SKILL.md and read by ahel’s review.

Complete MT5 Integration with Enterprise Features

Supported Brokers

BrokerDemo ServerNotes
RoboForexRoboForex-DemoLow spreads, fast execution
IC MarketsICMarketsSC-DemoPopular for scalping
PepperstonePepperstone-DemoAustralian broker
XMXMGlobal-DemoGlobal coverage
OANDAOANDA-v20 PracticeUS-friendly
Any MT5 BrokerCheck brokerWorks with any MT5 broker

Features

FeatureStatusDescription
Core TradingMarket/Limit/Stop Orders, Position Management
Multi-AccountManage unlimited accounts in parallel
Copy TradingMaster-Follower with multipliers
Strategy TesterBacktesting, Optimization, Walk-Forward
Signal ProviderTelegram/Discord/Webhook Broadcasting
Expert AdvisorBidirectional MQL5 Communication
VPS Deployment24/7 Production with Auto-Recovery

Installation

1. MetaTrader 5 Terminal

Download: https://www.metatrader5.com/download

Or from your broker's website.

2. Python Dependencies

pip install MetaTrader5 pandas numpy psutil requests flask

3. Optional for Extended Features

pip install ta-lib scikit-learn tensorflow  # ML/Technical Analysis

Quick Start

K.I.T. verbindet sich LOKAL zum bereits laufenden MT5 Terminal - KEINE Credentials nötig!

import MetaTrader5 as mt5

# Auto-Connect zum laufenden Terminal (KEINE LOGIN-DATEN!)
if mt5.initialize():
    print("✅ Verbunden mit MT5!")

    # Account Info holen
    account = mt5.account_info()
    print(f"Account: {account.login}")
    print(f"Balance: {account.balance} {account.currency}")

    # Trade ausführen
    request = {
        "action": mt5.TRADE_ACTION_DEAL,
        "symbol": "EURUSD",
        "volume": 0.1,
        "type": mt5.ORDER_TYPE_BUY,
        "price": mt5.symbol_info_tick("EURUSD").ask,
    }
    result = mt5.order_send(request)
    print(f"Order: {result}")

    mt5.shutdown()
else:
    print("❌ MT5 Terminal nicht gestartet!")

Voraussetzungen

  1. MT5 Terminal läuft und ist eingeloggt (manuell einmalig)
  2. Auto-Trading aktiviert (Button oben in MT5)
  3. Python auf gleichem PC wie MT5

K.I.T. braucht NIEMALS deine Login-Daten - das Terminal ist bereits authentifiziert!


Module Overview

1. MT5 Connector (mt5_connector.py)

Connection management with error handling.

import MetaTrader5 as mt5

# AUTO-CONNECT (empfohlen) - verbindet zum laufenden Terminal
if mt5.initialize():
    info = mt5.account_info()
    print(f"Balance: {info.balance} {info.currency}")
    print(f"Leverage: 1:{info.leverage}")

    # Trading allowed?
    if info.trade_allowed:
        print("Ready to trade!")

    mt5.shutdown()

# ALTERNATIVE: Spezifischen Account wählen (falls mehrere Terminals)
# mt5.initialize(login=123456, password="pass", server="Broker-Demo")

⚠️ K.I.T. fragt NIEMALS nach Passwörtern! Das MT5 Terminal ist bereits eingeloggt.

2. MT5 Orders (mt5_orders.py)

Complete order management.

from scripts.mt5_orders import MT5Orders

orders = MT5Orders()

# MARKET ORDER
result = orders.market_order(
    symbol="EURUSD",
    order_type="buy",
    volume=0.1,
    sl=1.0850,
    tp=1.1050
)
print(f"Order executed: Ticket #{result['ticket']}")

# LIMIT ORDER
orders.limit_order(
    symbol="EURUSD",
    order_type="buy_limit",
    volume=0.1,
    price=1.0900,
    sl=1.0850,
    tp=1.0980
)

# POSITION MANAGEMENT
positions = orders.get_positions()
for pos in positions:
    print(f"{pos['symbol']}: {pos['profit']:+.2f}")

# Close position
orders.close_position(ticket=123456789)
orders.close_all_positions(symbol="EURUSD")

3. MT5 Data (mt5_data.py)

Real-time market data and historical data.

from scripts.mt5_data import MT5Data

data = MT5Data()

# TICK DATA
tick = data.get_tick("EURUSD")
print(f"Bid: {tick['bid']}, Ask: {tick['ask']}")

# CANDLES (OHLCV)
candles = data.get_candles("EURUSD", "H1", 100)
print(candles.tail())

# SYMBOL INFO
info = data.get_symbol_info("EURUSD")
print(f"Contract Size: {info['trade_contract_size']}")
print(f"Min Volume: {info['volume_min']}")

Enterprise Features

4. Multi-Account Manager (mt5_multi_account.py)

Manage unlimited accounts simultaneously.

from scripts.mt5_multi_account import MT5MultiAccountManager, AccountConfig

manager = MT5MultiAccountManager()

# Add accounts
manager.add_account(AccountConfig(
    account_id=111111,
    password="pass1",
    server="Broker-Demo",
    name="Aggressive Account",
    max_risk_percent=5.0
))

manager.add_account(AccountConfig(
    account_id=222222,
    password="pass2",
    server="Broker-Demo",
    name="Conservative Account",
    max_risk_percent=1.0
))

# Trade on ALL accounts simultaneously
results = manager.execute_on_all("EURUSD", "buy", 0.1)

# Portfolio summary
summary = manager.get_portfolio_summary()
print(f"Total Balance: ${summary['total_balance']:,.2f}")

5. Strategy Tester (mt5_strategy_tester.py)

Professional backtesting with Monte Carlo simulation.

from scripts.mt5_strategy_tester import MT5StrategyTester, MovingAverageCrossStrategy

# Create tester
tester = MT5StrategyTester(initial_balance=10000)
tester.load_data("EURUSD", "H1", days=365)

# Run backtest
strategy = MovingAverageCrossStrategy()
result = tester.run_backtest(strategy, volume=0.1)

print(f"Backtest Results:")
print(f"  Total Trades: {result.total_trades}")
print(f"  Win Rate: {result.win_rate:.1f}%")
print(f"  Total Profit: ${result.total_profit:,.2f}")
print(f"  Profit Factor: {result.profit_factor:.2f}")
print(f"  Max Drawdown: {result.max_drawdown_percent:.1f}%")

# Optimization
opt_results = tester.optimize(
    strategy,
    param_grid={
        'fast_period': [5, 10, 15, 20],
        'slow_period': [20, 30, 40, 50]
    },
    metric='profit_factor'
)

6. Signal Provider (mt5_signal_provider.py)

Professional signal service with multi-channel broadcasting.

from scripts.mt5_signal_provider import MT5SignalProvider, SignalType

provider = MT5SignalProvider(
    provider_name="KIT_Signals",
    telegram_bot_token="your_bot_token"
)

# Add subscribers
provider.add_subscriber(Subscriber(
    id="sub1",
    telegram_chat_id="123456789"
))

# Create and broadcast signal
signal = provider.create_signal(
    signal_type=SignalType.MARKET_BUY,
    symbol="EURUSD",
    volume=0.1,
    sl=1.0850,
    tp=1.1000
)

results = provider.broadcast(signal)

7. VPS Deployment (mt5_vps_deployment.py)

Production-ready 24/7 trading infrastructure.

from scripts.mt5_vps_deployment import MT5VPSDeployment, VPSConfig

config = VPSConfig(
    account_id=123456,
    password="secure_pass",
    server="Broker-Live",
    watchdog_enabled=True,
    alert_telegram_chat="123456789"
)

vps = MT5VPSDeployment(config)
vps.start()

# Check status
status = vps.get_status()
print(f"Status: {status['status']}")
print(f"Uptime: {status['uptime_hours']:.1f} hours")

Timeframes

CodeMT5 ConstantDescription
M1TIMEFRAME_M11 Minute
M5TIMEFRAME_M55 Minutes
M15TIMEFRAME_M1515 Minutes
M30TIMEFRAME_M3030 Minutes
H1TIMEFRAME_H11 Hour
H4TIMEFRAME_H44 Hours
D1TIMEFRAME_D11 Day
W1TIMEFRAME_W11 Week

Error Codes

CodeMeaning
10004Requote
10006Authorization failed
10010Auto-Trading disabled
10013Invalid volume
10014Invalid price
10015Invalid stops
10019Not enough money

Security Best Practices

  1. NO CREDENTIALS NEEDED: K.I.T. connects to your already-logged-in MT5 Terminal - never give K.I.T. your password!
  2. Local Only: Python MT5 module only works on the same PC as the terminal
  3. Demo First: ALWAYS test in demo mode first
  4. Risk Management: Max 2% per trade, ALWAYS set Stop Loss
  5. VPS: Use dedicated VPS for 24/7 trading
  6. Monitoring: Enable alerts for critical events

🔒 K.I.T. NEVER asks for your MT5 login/password! If something asks for credentials, it's not the real K.I.T.


Testing

cd skills/metatrader

# Basic test
python examples/example_trade.py

# Unit tests
python -m pytest tests/

# Quick test
python examples/quick_test.py --trade

File Structure

skills/metatrader/
├── SKILL.md                    # This documentation
├── __init__.py                 # Package exports
├── scripts/
│   ├── mt5_connector.py        # Connection Management
│   ├── mt5_orders.py           # Order Execution
│   ├── mt5_data.py             # Market Data
│   ├── mt5_multi_account.py    # Multi-Account Manager
│   ├── mt5_strategy_tester.py  # Backtesting Engine
│   ├── mt5_signal_provider.py  # Signal Broadcasting
│   ├── mt5_expert_advisor.py   # MQL5 EA Bridge
│   └── mt5_vps_deployment.py   # VPS Infrastructure
└── examples/
    ├── 01_connect.py
    ├── 02_balance.py
    ├── 03_market_order.py
    └── quick_test.py

K.I.T. Commands

After integration, K.I.T. understands:

  • "Buy 0.1 lot EURUSD with 20 pip stop loss"
  • "Show my open positions"
  • "Close all losing trades"
  • "Backtest MA crossover on EURUSD last 6 months"
  • "Send signal to all subscribers"
  • "Status of all trading accounts"
  • "VPS health check"

Version: 2.0.0 Created: February 2026 Author: K.I.T. MetaTrader Agent

Signals

GitHub stars
136
Forks
870
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
metatrader
Source
github.com/signal-execution-labs/forex-trading-ai-agent