# marco210210/ai-enhanced-hft architecture

> Architecture diagram of the GitHub repository marco210210/ai-enhanced-hft, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marco210210/ai-enhanced-hft
- Repository: https://github.com/marco210210/ai-enhanced-hft

## Overview

This repository implements a MetaTrader 5 hybrid trading system: market data feeds an Expert Advisor (EA), which combines technical strategy signals with AI forecasts to size and manage trades. Forecasts are generated either in batch and saved as CSV, or served over TCP by the Python microservice. The README also documents H1 data export, three model families, and strategy-tester evaluation. EA internals and training workflows are not excerpted, so their relationships below rely on README statements rather than inspected implementation.

Main entry points: [`Hybrid_EA.mq5`](https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5) (Hybrid EA), [`model_rf/forecast_RF.py`](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_rf/forecast_RF.py) (Random Forest forecast), [`model_xgboost/forecast_xgboost.py`](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_xgboost/forecast_xgboost.py) (XGBoost forecast), [`model_lstm/forecast_lstm.py`](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_lstm/forecast_lstm.py) (LSTM forecast)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_trading["Trading strategy"]
  node_ea["Hybrid EA<br/>[Hybrid_EA.mq5]"]
  node_signals["Technical signals<br/>[Hybrid_EA.mq5]"]
  node_trade_management["Trade management<br/>[Hybrid_EA.mq5]"]
  node_forecast_input["Forecast integration<br/>[Hybrid_EA.mq5]"]
end

subgraph group_forecast["AI forecasting"]
  node_rf_forecast["Random Forest forecast<br/>[forecast_RF.py]"]
  node_xgb_forecast["XGBoost forecast"]
  node_lstm_forecast["LSTM forecast<br/>[forecast_lstm.py]"]
  node_rf_data["RF prepared data"]
  node_xgb_data["XGBoost prepared data"]
  node_lstm_data["LSTM prepared data"]
  node_rf_output["RF forecast CSV<br/>[forecast_RF.csv]"]
  node_xgb_output["XGBoost forecast CSV"]
  node_lstm_output["LSTM forecast CSV<br/>[forecast_lstm.csv]"]
  node_socket_service["TCP AI service<br/>[socket_ai.py]"]
end

subgraph group_data["Market data"]
  node_exporter["H1 exporter<br/>[Export_H1_Data.mq5]"]
  node_h1_data["H1 dataset<br/>[XAGUSD_H1_data.csv]"]
end

subgraph group_evaluation["Evaluation"]
  node_backtests["Backtest reports"]
end

node_market(("Market data"))
node_mt5["MetaTrader 5"]
node_tester["Strategy Tester"]

node_market -->|"provides prices"| node_ea
node_mt5 -->|"runs"| node_ea
node_ea -->|"computes"| node_signals
node_ea -->|"reads forecasts"| node_forecast_input
node_ea -->|"sizes and manages"| node_trade_management
node_exporter -.->|"exports"| node_h1_data
node_rf_data -->|"supplies features"| node_rf_forecast
node_rf_forecast -->|"writes"| node_rf_output
node_xgb_data -->|"supplies features"| node_xgb_forecast
node_xgb_forecast -->|"writes"| node_xgb_output
node_lstm_data -->|"supplies sequences"| node_lstm_forecast
node_lstm_forecast -->|"writes"| node_lstm_output
node_socket_service -->|"serves predictions"| node_forecast_input
node_rf_output -.->|"read during backtest"| node_forecast_input
node_xgb_output -.->|"read during backtest"| node_forecast_input
node_lstm_output -.->|"read during backtest"| node_forecast_input
node_tester -->|"backtests"| node_ea
node_tester -.->|"produces reports"| node_backtests

click node_ea "https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5"
click node_signals "https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5"
click node_trade_management "https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5"
click node_forecast_input "https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5"
click node_exporter "https://github.com/marco210210/ai-enhanced-hft/blob/main/Export_H1_Data.mq5"
click node_h1_data "https://github.com/marco210210/ai-enhanced-hft/blob/main/XAGUSD_H1_data.csv"
click node_rf_forecast "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_rf/forecast_RF.py"
click node_xgb_forecast "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_xgboost/forecast_xgboost.py"
click node_lstm_forecast "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_lstm/forecast_lstm.py"
click node_rf_data "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_rf/randomforest_ready_dataset.csv"
click node_xgb_data "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_xgboost/xgboost_ready_dataset.csv"
click node_lstm_data "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_lstm/lstm_ready_dataset.csv"
click node_rf_output "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_rf/forecast_RF.csv"
click node_xgb_output "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_xgboost/forecast_XGBoost.csv"
click node_lstm_output "https://github.com/marco210210/ai-enhanced-hft/blob/main/model_lstm/forecast_lstm.csv"
click node_socket_service "https://github.com/marco210210/ai-enhanced-hft/blob/main/socket_ai.py"
click node_backtests "https://github.com/marco210210/ai-enhanced-hft/tree/main/backtest_ema6-24"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ea,node_signals,node_trade_management,node_forecast_input toneBlue
class node_rf_forecast,node_xgb_forecast,node_lstm_forecast,node_rf_data,node_xgb_data,node_lstm_data,node_rf_output,node_xgb_output,node_lstm_output,node_socket_service toneAmber
class node_exporter,node_h1_data toneMint
class node_backtests toneRose
class node_market,node_mt5,node_tester toneIndigo
```

## Components

### Trading strategy

- [Hybrid EA](https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5): `Hybrid_EA.mq5`
- [Technical signals](https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5): `Hybrid_EA.mq5`
- [Trade management](https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5): `Hybrid_EA.mq5`
- [Forecast integration](https://github.com/marco210210/ai-enhanced-hft/blob/main/Hybrid_EA.mq5): `Hybrid_EA.mq5`

### AI forecasting

- [Random Forest forecast](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_rf/forecast_RF.py): `model_rf/forecast_RF.py`
- [XGBoost forecast](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_xgboost/forecast_xgboost.py): `model_xgboost/forecast_xgboost.py`
- [LSTM forecast](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_lstm/forecast_lstm.py): `model_lstm/forecast_lstm.py`
- [RF prepared data](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_rf/randomforest_ready_dataset.csv): `model_rf/randomforest_ready_dataset.csv`
- [XGBoost prepared data](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_xgboost/xgboost_ready_dataset.csv): `model_xgboost/xgboost_ready_dataset.csv`
- [LSTM prepared data](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_lstm/lstm_ready_dataset.csv): `model_lstm/lstm_ready_dataset.csv`
- [RF forecast CSV](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_rf/forecast_RF.csv): `model_rf/forecast_RF.csv`
- [XGBoost forecast CSV](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_xgboost/forecast_XGBoost.csv): `model_xgboost/forecast_XGBoost.csv`
- [LSTM forecast CSV](https://github.com/marco210210/ai-enhanced-hft/blob/main/model_lstm/forecast_lstm.csv): `model_lstm/forecast_lstm.csv`
- [TCP AI service](https://github.com/marco210210/ai-enhanced-hft/blob/main/socket_ai.py): `socket_ai.py`

### Market data

- [H1 exporter](https://github.com/marco210210/ai-enhanced-hft/blob/main/Export_H1_Data.mq5): `Export_H1_Data.mq5`
- [H1 dataset](https://github.com/marco210210/ai-enhanced-hft/blob/main/XAGUSD_H1_data.csv): `XAGUSD_H1_data.csv`

### Evaluation

- [Backtest reports](https://github.com/marco210210/ai-enhanced-hft/tree/main/backtest_ema6-24): `backtest_ema6-24`

### Other components

- **Market data**
- **MetaTrader 5**
- **Strategy Tester**

## Connections

- Market data → Hybrid EA: provides prices (evidence: `README.md`)
- MetaTrader 5 → Hybrid EA: runs (evidence: `README.md`)
- Hybrid EA → Technical signals: computes (evidence: `README.md`)
- Hybrid EA → Forecast integration: reads forecasts (evidence: `README.md`)
- Hybrid EA → Trade management: sizes and manages (evidence: `README.md`)
- H1 exporter → H1 dataset: exports (evidence: `README.md`)
- RF prepared data → Random Forest forecast: supplies features (evidence: `model_rf/forecast_RF.py`)
- Random Forest forecast → RF forecast CSV: writes (evidence: `model_rf/forecast_RF.py`)
- XGBoost prepared data → XGBoost forecast: supplies features (evidence: `model_xgboost/forecast_xgboost.py`)
- XGBoost forecast → XGBoost forecast CSV: writes (evidence: `model_xgboost/forecast_xgboost.py`)
- LSTM prepared data → LSTM forecast: supplies sequences (evidence: `model_lstm/forecast_lstm.py`)
- LSTM forecast → LSTM forecast CSV: writes (evidence: `model_lstm/forecast_lstm.py`)
- TCP AI service → Forecast integration: serves predictions (evidence: `README.md`)
- RF forecast CSV → Forecast integration: read during backtest (evidence: `README.md`)
- XGBoost forecast CSV → Forecast integration: read during backtest (evidence: `README.md`)
- LSTM forecast CSV → Forecast integration: read during backtest (evidence: `README.md`)
- Strategy Tester → Hybrid EA: backtests (evidence: `README.md`)
- Strategy Tester → Backtest reports: produces reports (evidence: `README.md`)
