Skip to content

13otKmdr/MT5-AlgoLab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

654 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MT5-AlgoLab

Automated NNFX Strategy Discovery & Backtesting System

A systematic approach to discovering and validating profitable trading strategies using the No Nonsense Forex (NNFX) methodology. Automates the full pipeline from indicator screening to portfolio backtesting.

Python MetaTrader 5 AI


What It Does

📊 Strategy Discovery - Screen 40+ indicators for edge across multiple timeframes
🧪 Backtesting - Full position engine with money management rules
📈 Portfolio Optimization - Combine strategies with correlation analysis
🤖 AI Analysis - Claude-powered strategy interpretation and reporting


Architecture

``` ┌─────────────────────────────────────────────────────────────┐ │ Discovery Pipeline │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ Stage 1 │ → │ Stage 2 │ → │ Stage 3 │ → │ Stage 4 │ │ │ │Indicator │ │Baseline │ │Confirm │ │Portfolio │ │ │ │Screening │ │ Entry │ │ Exit │ │ Building │ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ ↓ ↓ ↓ ↓ │ │ [40+ indicators] [Entry signals] [Exit rules] [Correlation]│ └─────────────────────────────────────────────────────────────┘ │ ↓ ┌─────────────────────────────────────────────────────────────┐ │ Backtesting Engine │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │ │ │Position Engine│ │Risk Manager │ │ Performance Stats│ │ │ │• Entry/Exit │ │• Position │ │• Win rate │ │ │ │• Stop Loss │ │ sizing │ │• Profit factor │ │ │ │• Take Profit │ │• Exposure │ │• Drawdown │ │ │ └──────────────┘ └──────────────┘ └──────────────────┘ │ └─────────────────────────────────────────────────────────────┘ │ ↓ ┌─────────────────────────────────────────────────────────────┐ │ AI Analysis Layer │ │ ┌──────────────────────────────────────────────────────┐ │ │ │ Claude API → Strategy interpretation & reporting │ │ │ └──────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────┘ ```


Tech Stack

Layer Technology
Language Python 3.10+
Trading Platform MetaTrader 5 (MT5)
Data MT5 API, Pandas, NumPy
Indicators 42 Python-native implementations
Backtesting Custom position engine
AI Anthropic Claude API
Visualization Streamlit dashboard

Quick Start

```bash

Clone

git clone https://github.com/13otKmdr/MT5-AlgoLab.git cd MT5-AlgoLab

Install

pip install -r requirements.txt

Verify MT5 connection (terminal must be running)

python DiscoveryEngine/health_check.py

Run discovery

python execution/run_discovery.py --category crypto --timeframe H1 ```


Key Features

NNFX Methodology Implementation

Full implementation of the No Nonsense Forex approach:

  • Indicator screening with robustness testing
  • Baseline entry signal validation
  • Confirmation indicator pairing
  • Exit strategy optimization

42 Native Indicators

Python implementations of popular indicators:

  • Trend: EMA, SMA, Hull MA, Ichimoku
  • Momentum: RSI, CCI, MACD, Stochastic
  • Volatility: ATR, Bollinger, Keltner
  • Volume: OBV, VWAP

Full Backtesting Engine

  • Position-level simulation
  • Stop loss and take profit
  • Money management rules
  • Currency exposure limits
  • Performance metrics (Sharpe, drawdown, win rate)

AI-Powered Analysis

Claude interprets backtest results and generates:

  • Strategy summaries
  • Trade rationale explanations
  • Risk assessments
  • Portfolio recommendations

Streamlit Dashboard

  • Real-time discovery progress
  • Backtest visualizations
  • Equity curves
  • Trade statistics

Project Structure

``` MT5-AlgoLab/ ├── DiscoveryEngine/ # NNFX discovery pipeline │ ├── bridge/ # MT5 terminal communication │ ├── logic/ # NNFX validation rules │ └── config/ # Discovery configurations ├── StrategyFactory/ # Deep backtesting │ ├── backtesting/ # Position engine │ ├── strategies/ # Strategy implementations │ └── risk/ # Exposure management ├── execution/ # Orchestration scripts │ ├── indicators_library.py # 42 indicators │ └── run_discovery.py # Main pipeline ├── dashboard/ # Streamlit UI ├── database/ # Results storage └── output/ # Generated reports ```


What I Learned Building This

Systematic Trading Research: Implementing a rigorous, repeatable process for strategy discovery rather than discretionary trading.

Python + MT5 Integration: Building a bridge between Python's data science ecosystem and MetaTrader's trading capabilities.

Position-Level Backtesting: Creating a realistic backtesting engine that accounts for position sizing, exposure limits, and money management rules.

AI-Assisted Analysis: Using LLMs to interpret quantitative results and generate human-readable strategy reports.

Large-Scale Parameter Optimization: Running thousands of indicator combinations efficiently with proper statistical validation.


Requirements

  • Python 3.10+
  • MetaTrader 5 terminal (running)
  • Anthropic API key (for AI analysis)
  • Windows (for MT5 integration) or Wine on Linux

License

MIT


Automated NNFX strategy discovery and backtesting

About

Automated NNFX Strategy Discovery & Backtesting System for MetaTrader 5

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors