Skip to content

KaisElabanie/meta5-strategy-forge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

📈 MetaTitan Strategy Engine – Enterprise-Grade Algorithmic Trading Framework for MetaTrader 5

Download

Welcome to the MetaTitan Strategy Engine – a comprehensive, open-source repository designed for quantitative traders, financial engineers, and algorithmic enthusiasts who demand precision, scalability, and innovation in their MetaTrader 5 (MT5) workflows. This is not just another collection of Expert Advisors (EAs); it is a modular trading ecosystem that transforms raw market data into actionable intelligence, powered by MQL5 and complemented by external AI integrations.


🚀 Overview: Beyond Backtesting, Into Autonomous Trading

Traditional trading bots are brittle—they follow static rules and fail under regime shifts. The MetaTitan Strategy Engine is built on the principle of adaptive resilience. Think of it as a digital trading architect that designs, tests, and deploys strategies with the flexibility of a living organism. It merges the proven stability of MQL5 with the emergent capabilities of Large Language Models (LLMs) like OpenAI and Claude, creating a feedback loop where code evolves alongside market conditions.

Core Philosophy: Your trading strategy should be a conversation, not a monologue. This engine allows you to converse with your code, optimize it through AI suggestions, and deploy it with confidence—all within the MT5 environment.


🧩 Key Features & Capabilities

🧠 AI-Enhanced Strategy Generation

  • OpenAI & Claude API Integration: Describe your trading hypothesis in natural language (e.g., "Capture momentum after low-volatility breakouts in EURUSD using adaptive trailing stops") and receive a ready-to-compile MQL5 Expert Advisor.
  • Automated Parameter Optimization: AI suggestions for stop-loss, take-profit, and lot-sizing based on historical volatility patterns.
  • Explainable AI Logs: Every trade decision comes with a natural language explanation, helping you understand why a position was opened or closed.

🌐 Multilingual Trading Oracle

  • Strategy documentation and console output available in English, Chinese, Spanish, Arabic, and Russian.
  • Dynamic localization of error messages, trade reports, and UI elements within the MT5 terminal.

📊 Responsive Dashboard UI

  • Real-time HTML-based dashboard (exportable to MT5’s WebRequest) that visualizes:
    • Equity curves with Monte Carlo simulation overlays.
    • Drawdown heatmaps (spatiotemporal risk analysis).
    • Live sentiment scores from LLM analysis of news headers.
  • Fully responsive: works on desktop, tablet, and mobile browsers through MT5’s internal web server.

24/7 Autonomous Operation

  • Built-in watchdog mechanism that restarts Expert Advisors after unexpected shutdowns or connectivity losses.
  • Cloud-based health monitoring via a lightweight REST API (optional integration with health checks.io).

🛡️ Enterprise Security & Compliance

  • All API keys (OpenAI, Claude, MT5 account credentials) are encrypted using AES-256 at rest.
  • Optional air-gapped mode – no external network requests required for trading logic (AI features become local suggestions).
  • Comprehensive audit logging: every variable change, trade execution, and configuration modification is timestamped and hashed.

📈 Advanced Backtesting Suite

  • Multi-symbol, multi-timeframe simultaneous backtesting.
  • Walk-forward analysis with built-in statistical significance tests (p-value estimation for strategy robustness).
  • Custom slippage and commission models – realistic simulation of broker execution.

🗺️ System Architecture (Mermaid Diagram)

graph TD
    A[User Input: Strategy Description] --> B{OpenAI / Claude API}
    B -->|Returns MQL5 Code Skeleton| C[Code Validator & Security Scanner]
    C --> D{Compilation Engine}
    D -->|Success| E[Expert Advisor .ex5]
    D -->|Failure| F[AI Error Analysis & Correction Loop]
    F --> B
    
    E --> G[MT5 Terminal]
    G --> H[Trade Executor]
    H --> I[Exchange / Broker Server]
    
    G --> J[Local Logs & Metrics]
    J --> K[HTML Dashboard Generator]
    K --> L[Responsive UI: Desktop/Mobile]
    
    G --> M[Watchdog Service]
    M --> G
    
    N[Market Data Feed] --> G
    O[News Sentiment API] --> B
    P[Claude API: Strategy Critique] --> A
Loading

⚙️ Installation & Setup

Prerequisites

  • MetaTrader 5 build 4000 or later
  • Windows 10/11, macOS (via CrossOver/Parallels), or Linux (via Wine 8.0+)
  • OpenAI API key (optional, for AI features)
  • Claude API key (optional, for alternative AI suggestions)

Quick Start

  1. Clone this repository into your MetaTrader 5/MQL5/Experts/ directory.
  2. Open MetaTrader 5 → Tools → Options → Expert Advisors → Enable DLL imports and WebRequest.
  3. Compile the MetaTitanEngine.mq5 file in MetaEditor.
  4. Drag the Expert Advisor onto any chart.
  5. Configure the userProfile JSON file (see below).

📝 Example Profile Configuration

The engine reads a profile.json file stored in the Files folder of your MT5 installation. This defines your trading identity, risk preferences, and AI interaction parameters.

{
  "trader": {
    "name": "AlphaTrader_01",
    "riskPerTrade": 1.5,
    "maxDrawdownPercent": 12,
    "preferredInstruments": ["EURUSD", "GBPUSD", "XAUUSD"],
    "timeframe": "H1"
  },
  "aiIntegrations": {
    "openai": {
      "model": "gpt-4-turbo",
      "temperature": 0.3,
      "maxTokens": 2000
    },
    "claude": {
      "model": "claude-3-opus-20240229",
      "maxTokensToSample": 1500
    }
  },
  "localization": {
    "language": "es", 
    "timezone": "America/New_York"
  },
  "dashboard": {
    "enabled": true,
    "refreshIntervalSeconds": 5,
    "customCSS": "styles/myDarkMode.css"
  }
}

💻 Example Console Invocation

Once the EA is running on a chart, you can invoke the MetaTitan CLI directly from the MT5 Expert Journal tab by sending a message using the Print() function. Alternatively, use the built-in REST endpoint.

sequenceDiagram
    participant U as User
    participant E as EA on Chart
    participant C as Console (Journal)
    
    U->>E: Send command: "analyze GBPUSD volatility"
    E->>E: Parse command & fetch data
    E->>C: [MetaTitan] Analyzing GBPUSD H1 volatility...
    E->>C: [MetaTitan] Current ATR(14): 0.00345
    E->>C: [MetaTitan] Regime detected: Ranging (low volatility)
    E->>C: [MetaTitan] Suggested strategy: Mean-reversion with Bollinger Bands (period=22, std=2.5)
    E->>C: [MetaTitan] Type 'deploy mean-reversion' to activate.
Loading

Supported Console Commands:

  • status – Show current balance, equity, open positions.
  • deploy <strategy_name> – Activate a predefined strategy.
  • optimize <symbol> <timeframe> – Run AI-driven parameter optimization.
  • report – Export full trading report as .csv or .html.
  • language <code> – Switch UI language (e.g., language zh for Chinese).
  • help – Display all available commands.

🖥️ Operating System Compatibility

OS Support Status Notes
🟢 Windows 10/11 Fully supported Native MQL5 execution
🟢 Windows Server 2019+ Fully supported Ideal for cloud deployment
🟡 macOS (Intel/Apple Silicon) Compatible via CrossOver Requires Wine 8.0; limited WebRequest
🟡 Linux (Ubuntu 22.04+) Compatible via Wine Performance may vary; enable DLL stubs
🔴 iOS / Android Not supported MT5 mobile cannot run Expert Advisors

🧪 AI Integration Deep-Dive

OpenAI API Integration

  • Use case: Generate trading logic from natural language specifications.
  • Endpoint: POST /v1/chat/completions
  • Prompt engineering: The engine prepends a system prompt defining MQL5 syntax rules, MT5 API constraints, and risk management guidelines.
  • Fallback: If the API is unreachable, the engine uses a local rule-based generator.

Claude API Integration

  • Use case: Strategy critique and performance analysis. Claude reviews your existing EA code and suggests improvements (e.g., reducing slippage, better position sizing).
  • Endpoint: POST /v1/messages
  • Context window: Claude receives the last 100 trades (as structured JSON) plus the current EA code, then returns a report with confidence scores for each suggestion.

Example output from Claude:

"Your trailing stop is too tight for XAUUSD (average movement 0.8%). Consider increasing it to 1.2% to avoid whipsaw losses. Confidence: 82%."


📚 Comprehensive Documentation

All documentation is generated and maintained by an AI assistant – if you spot an error, feel free to open a pull request!


🤝 Contribution Guidelines

We welcome contributions that align with our three pillars: reliability, transparency, and innovation. By contributing, you agree to the MIT License.

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/your-idea.
  3. Commit changes with descriptive messages (e.g., feat: add adaptive trailing stop for trending markets).
  4. Push to your fork and submit a Pull Request.
  5. All PRs must include:
    • Unit tests for any new MQL5 functions.
    • Updated documentation in the /docs folder.
    • A sample configuration in /examples.

Code Style: Use the MQL5 Standard Library conventions (Hungarian notation for variables, comments above functions, and 80-character line limits).


⚠️ Disclaimer

Use at your own risk. Trading foreign exchange, cryptocurrencies, and other financial instruments carries substantial risk of loss and is not suitable for every investor. Past performance is not indicative of future results.

  • The MetaTitan Strategy Engine is provided as-is without any warranty, express or implied.
  • The AI-generated trading strategies (via OpenAI, Claude, or any other model) are suggestive and should be validated through independent backtesting and forward testing on demo accounts.
  • The authors, contributors, and affiliated entities are not responsible for any financial losses, data breaches, or system failures resulting from the use of this software.
  • Regulatory compliance: It is your responsibility to ensure that algorithmic trading is permitted by your broker and jurisdiction. This software does not constitute financial advice.

By using this repository, you acknowledge that you have read, understood, and agreed to the above terms.


📄 License

This project is licensed under the MIT License – a permissive open-source license that allows you to use, modify, distribute, and sell the software, provided you include the original copyright notice.

MIT License


📥 Download & Links

Download


"The market is a complex adaptive system. Your trading engine should be one too." – MetaTitan Philosophy, 2026

Happy algorithmic trading! May your drawdowns be shallow and your Sharpe ratios high. 📊🚀