An intelligent algorithmic trading system that combines grid trading with DeepSeek AI LLM analysis, real-time news filtering, and automated risk management for forex scalping on MetaTrader 5. Best free AI forex trading bot for EURUSD, GBPUSD, and USDJPY scalping.
Quick Start | Architecture | EA Variants | Configuration | Backtesting | FAQ | Contributing
What: Open-source (MIT) MetaTrader 5 Expert Advisor — MQL5 grid trading + optional Python 3.11 FastAPI backend. AI: DeepSeek LLM generates BUY/SELL/HOLD signals with confidence scores and a 0-100% risk score. News: Real-time NewsAPI sentiment filtering with automatic caution mode 30 min before high-impact events. Risk: Circuit breakers (daily loss limit 10%, max drawdown 15%), AI-adjusted position sizing and stop losses. Cost: Free software. NewsAPI free tier + ~$5 DeepSeek credits lasts months. Setup: 5 minutes standalone (copy .mq5 → compile → enter API keys). Docker one-liner for the backend. Pairs: EURUSD, GBPUSD, USDJPY (liquid majors). Best session: London/NY overlap 12:00–16:00 UTC. Regions: Optimized for Europe (London) and Americas (New York) forex sessions. Works globally with timezone-aware scheduling. Languages: English documentation. MQL5 code supports all MetaTrader 5 broker languages.
| DAX AI Grid Scalper | Typical MT5 EA | Manual Trading | |
|---|---|---|---|
| Market analysis | DeepSeek LLM + news sentiment | Fixed rules only | Human judgment |
| Adaptability | Dynamic risk scoring 0-100% | Static parameters | Emotional |
| News awareness | Automatic caution mode | None | Manual checking |
| Operation | 24/5 automated | 24/5 automated | Limited hours |
| Risk controls | AI-adjusted circuit breakers | Basic SL/TP | Discipline-dependent |
| Source code | Fully open (MIT) | Usually closed | N/A |
| Cost | Free + cheap APIs | $50-$5000+ | Time |
| Feature | Description |
|---|---|
| DeepSeek AI Integration | LLM-powered market analysis with professional-grade insights |
| Sentiment Analysis | Real-time news sentiment scoring for currency pairs |
| Signal Generation | AI-driven BUY/SELL/HOLD recommendations with confidence levels |
| Risk Scoring | 0-100% dynamic risk assessment based on technical + fundamental data |
| Feature | Description |
|---|---|
| Breakout Grid System | Dynamic grid placement based on price action |
| Smart Position Sizing | AI-adjusted lot sizes based on current risk score |
| Adaptive Stop Loss | ATR-based dynamic stops with AI optimization |
| Trailing & Break-Even | Automated profit protection mechanisms |
| Fibonacci Grid | Fibonacci-based grid spacing for trend-following |
| Multiple Timeframes | M5, M15 support with optimized parameters |
| Feature | Description |
|---|---|
| NewsAPI Integration | Live forex news from 100,000+ sources |
| Economic Calendar | High-impact event detection and alerts |
| News Caution Mode | Automatic risk reduction 30min before major news |
| Sentiment Scoring | NLP-based market sentiment from news analysis |
| Feature | Description |
|---|---|
| Circuit Breakers | Daily loss and drawdown limits with auto-close |
| AI-Adjusted Limits | Tighter limits when AI detects elevated risk |
| Position Size Enforcement | Maximum risk per trade strictly enforced |
| Spread Protection | Dynamic spread filtering during volatility |
┌──────────────────────────────────────────────────────────────────┐
│ DAX AI Trading System │
├─────────────────────────┬────────────────────────────────────────┤
│ MetaTrader 5 (EA) │ FastAPI Backend (Python) │
│ │ │
│ ┌───────────────────┐ │ ┌──────────────────────────────────┐ │
│ │ Grid Trading │ │ │ DeepSeek AI Service │ │
│ │ Order Execution │ │ │ ├── Market Analysis │ │
│ │ Risk Checks │ │ │ ├── Signal Generation │ │
│ │ Dashboard (HTML) │ │ │ └── Risk Scoring │ │
│ └───────────────────┘ │ └──────────────────────────────────┘ │
│ │ │
│ ┌───────────────────┐ │ ┌──────────────────────────────────┐ │
│ │ MQ5 Modules │ │ │ News Service │ │
│ │ ├── DeepSeekAI │ │ │ ├── NewsAPI Integration │ │
│ │ └── NewsAPI │ │ │ ├── Sentiment Analysis │ │
│ └───────────────────┘ │ │ └── Economic Calendar │ │
│ │ └──────────────────────────────────┘ │
│ │ │
│ │ ┌──────────────────────────────────┐ │
│ │ │ Risk Management │ │
│ │ │ ├── Circuit Breakers │ │
│ │ │ ├── Position Sizing │ │
│ │ │ └── Dynamic SL/TP │ │
│ │ └──────────────────────────────────┘ │
└─────────────────────────┴────────────────────────────────────────┘
│ HTTP (REST) │
└──────────────────────────────────┘
| Mode | How It Works | Best For |
|---|---|---|
| Standalone | EA calls DeepSeek + NewsAPI directly via HTTP | Simple setup, single PC |
| FastAPI | EA calls Python backend, backend handles AI | Multi-device, advanced risk, scalability |
GridScalperEA/
├── DeepSeekNewsGridScalper_V2.mq5 # Main standalone EA (800+ lines)
├── Include/
│ ├── DeepSeekAI.mqh # AI integration module
│ └── NewsAPI.mqh # News API integration
├── Config/
│ └── EA_Config.ini # EA configuration
├── Backend/ # Python FastAPI Backend
│ ├── app/
│ │ ├── main.py # FastAPI entry point
│ │ ├── core/ # Config & database
│ │ ├── routers/ # API route handlers
│ │ ├── services/ # Business logic
│ │ └── models/ # Pydantic schemas
│ ├── Dockerfile # Docker build
│ ├── docker-compose.yml # Docker orchestration
│ ├── requirements.txt # Python dependencies
│ └── .env.example # Environment template
├── MQ5_FastAPI/ # FastAPI-connected EA variants
│ ├── EAFastConnector.mq5 # Main FastAPI EA
│ ├── DAX_M5_Standalone.mq5 # M5 standalone
│ ├── DAX_FibATR_Trend.mq5 # Fibonacci ATR trend
│ └── Fibonation_Grid.mq5 # Fibonacci grid
├── tools/ # Research & optimization scripts
├── docs/
│ └── index.html # Landing page (GitHub Pages)
└── Scripts/
└── TestAPIs.mq5 # API testing
1. Get API Keys
| API | Cost | Sign Up |
|---|---|---|
| NewsAPI | Free (100 req/day) | newsapi.org/register |
| DeepSeek AI | ~$5 for months | platform.deepseek.com |
2. Install in MetaTrader 5
# Copy BOTH items into MQL5/Experts/ (the EA + its Include folder next to it)
Copy DeepSeekNewsGridScalper_V2.mq5 → MQL5/Experts/
Copy Include/ → MQL5/Experts/Include/The EA uses relative includes (
"Include\NewsAPI.mqh"), soInclude/must sit next to the .mq5 file insideMQL5/Experts/.
3. Compile & Configure
- Open MetaEditor, press
F7to compile - Drag EA onto EURUSD chart (H1 or H4)
- Enter API keys in EA inputs
- Enable "Allow WebRequest" with these URLs:
https://api.newsapi.orghttps://api.deepseek.com
4. Verify
Check Experts tab for AI Analysis: ENABLED and the on-chart dashboard.
# Clone the repo
git clone https://github.com/foeed/GridScalperEA.git
cd GridScalperEA/Backend
# Setup environment
copy .env.example .env
# Edit .env with your API keys
# Run with Docker (recommended)
docker-compose up -d
# OR run locally
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reloadThen configure the EA to point to http://localhost:8000.
Full backend details: README_FastAPI.md · Setup walkthrough: QUICKSTART.md
| EA | Strategy | Timeframe | Mode | Best For |
|---|---|---|---|---|
| DeepSeekNewsGridScalper_V2 | Grid + AI + News | M1-H4 | Standalone | Full-featured trading |
| EAFastConnector | Grid + Backend | M1-H4 | FastAPI | Scalable setup |
| DAX_M5_Standalone | Grid (M5 optimized) | M5 | Standalone | Scalping |
| DAX_FibATR_Trend | Fibonacci ATR Trend | M5-M30 | Standalone | Trend following |
| Fibonation_Grid | Fibonacci Grid | M5 | Standalone | Grid with Fib spacing |
| Profile | Risk/Trade | Daily Loss | Grid Orders | Grid Distance | Suitable For |
|---|---|---|---|---|---|
| Conservative | 1.0% | 5.0% | 1 | 400 | Beginners |
| Standard | 2.0% | 10.0% | 2 | 300 | Most traders |
| Aggressive | 3.0% | 15.0% | 3 | 250 | Experienced |
| Parameter | Default | Description |
|---|---|---|
UseAIAnalysis |
true |
Enable DeepSeek AI analysis |
UseNewsFilter |
true |
Enable news-based filtering |
AIAnalysisInterval |
300 |
Seconds between AI calls |
MaxRiskPerTrade |
2.0% |
Maximum risk per trade |
DynamicPositionSizing |
true |
AI-adjusted lot sizes |
DynamicStopLoss |
true |
AI-adjusted stop losses |
| Parameter | Default | Action |
|---|---|---|
MaxDailyLoss |
10.0% |
Close all positions |
MaxDrawdown |
15.0% |
Emergency stop trading |
AIAdjustedLimits |
true |
Tighter limits when AI risk > 70% |
Risk Score = Technical (30%) + Volatility (30%) + News (20%) + AI Confidence (20%)
0-30% → Low Risk → Full position sizes
30-60% → Medium Risk → Reduced position sizes
60-80% → High Risk → Minimal trading
80-100% → Extreme → No new trades
- 30 min before high-impact news → Caution mode activated
- Position sizes cut by 50%
- Spread limits tightened by 20%
- Only high-confidence trades allowed
POST /api/v1/trading/signal # Get AI trading signal
POST /api/v1/trading/analyze # Full market analysis
GET /api/v1/trading/dashboard # Dashboard data
POST /api/v1/risk/assess # Risk assessment
POST /api/v1/risk/position-size # Position sizing
POST /api/v1/risk/dynamic-sl # Dynamic stop loss
POST /api/v1/risk/circuit-breakers # Circuit breaker check
GET /api/v1/news/{symbol} # Get forex news
GET /api/v1/news/{symbol}/sentiment # Sentiment score
GET /api/v1/news/{symbol}/high-impact # High impact check
Full API docs available at http://localhost:8000/docs (Swagger UI).
The system has been backtested across multiple strategies and timeframes:
| Strategy | Timeframe | Period | Key Metrics |
|---|---|---|---|
| Grid Scalper | M5 | 30-90 days | XAUUSD optimization |
| Fibonacci Grid | M5 | 30 days | Fib spacing analysis |
| FibATR Trend | M5 | 30 days | ATR-based entries |
Research and optimization scripts live in tools/ for running your own experiments.
Disclaimer: Past performance does not guarantee future results. Always test on demo accounts first.
| Tier | Pairs |
|---|---|
| Primary | EURUSD, GBPUSD, USDJPY |
| Secondary | EURGBP, AUDUSD, USDCAD |
| Avoid | Exotics (USDTRY, USDZAR), minor pairs off-hours |
| Session | Time (UTC) | Local Time | Rating | Liquidity |
|---|---|---|---|---|
| London | 07:00-16:00 | GMT/BST | Good | High |
| New York | 12:00-21:00 | EST/EDT | Good | High |
| Overlap | 12:00-16:00 | — | Best | Highest |
| Tokyo | 23:00-08:00 | JST | Avoid | Low |
| Sydney | 22:00-07:00 | AEST | Avoid | Low |
| Region | Timezone | Best Session (UTC) | Recommended Pairs | Strategy |
|---|---|---|---|---|
| Europe (London) | GMT/BST | 07:00-16:00 | EURUSD, EURGBP, GBPUSD | Grid + News filter |
| Americas (New York) | EST/EDT | 12:00-21:00 | GBPUSD, USDJPY, USDCAD | Trend + AI signals |
| Asia (Tokyo) | JST | 23:00-08:00 | USDJPY, EURJPY | Conservative only |
| Global Overlap | — | 12:00-16:00 | All majors | Best scalping window |
| Tier | Pairs | Spreads | Best For |
|---|---|---|---|
| Primary (Global) | EURUSD, GBPUSD, USDJPY | Low | All sessions |
| European | EURGBP, EURCHF, GBPCHF | Medium | London session |
| American | USDJPY, USDCAD, USDCHF | Medium | New York session |
| Avoid | Exotics (USDTRY, USDZAR) | High | Any session |
Pro Tip: The London/New York overlap (12:00-16:00 UTC) provides the highest liquidity and tightest spreads for AI-powered grid trading.
- V3: Multi-pair portfolio management
- V3: Custom indicator integration
- V3: Web dashboard for monitoring
- V3: Telegram bot notifications
- V3: Backtesting module in FastAPI
- V3: Machine learning signal filtering
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
| Document | Contents |
|---|---|
| QUICKSTART.md | Step-by-step install walkthrough |
| README_FastAPI.md | Backend architecture + full API reference |
| CHANGELOG.md | Release history |
| CONTRIBUTING.md | How to contribute |
| SECURITY.md | Security policy + API key safety |
| docs/index.html | Landing page |
docs/llms.txt |
LLM/AI-assistant project briefing |
If you find this project useful, consider supporting development:
| Network | Currency | Address |
|---|---|---|
| BSC (BEP20) | USDT | 0xb13d29622961004b54c15452a233a43215331fe2 |
You can send any BEP20 token to the address above. Thank you for your support!
This project is licensed under the MIT License - see the LICENSE file for details.
This Expert Advisor and all associated code is for educational and research purposes only. Trading foreign exchange on margin carries a high level of risk and may not be suitable for all investors. Past performance is not indicative of future results. Always trade responsibly and never risk money you cannot afford to lose. The authors are not responsible for any financial losses incurred from using this software.
AI forex trading MT5 expert advisor automated grid trading DeepSeek AI MetaTrader 5 bot forex scalping algorithmic trading MQL5 Python FastAPI forex news filter trading bot free EURUSD bot GBPUSD scalper forex risk management open source trading
Built with DeepSeek AI, MetaTrader 5, Python FastAPI, and Docker