Algorithmic Trading · MetaTrader 5

A precision-built
multi-strategy trading engine

An event-driven algorithmic trading bot with four independent strategies, an AI market-regime filter, a full risk management stack, and a multi-client rental portal — all running on your MetaTrader 5 account.

Strategies
4
Independent vote
Primary TF
M15
Event-driven on candle close
Stop Loss
1.5×
ATR(14) multiplier
R:R Ratio
2 : 1
Fixed reward-to-risk
Risk / Trade
1.0%
Of account equity
Min Score
0.55
To trigger a trade

Execution Pipeline

Every trade flows through eight stages. Each stage can veto — a trade only fires when all gates pass.

01

Candle Close

M15 event fires; pipeline starts

02

Strategy Engine

4 strategies run in parallel

03

Signal Vote

Weighted consensus + min score

04

AI Regime

ADX / ATR / Volume filter

05

Portfolio Check

Exposure + correlation guard

06

Risk Sizing

Lot calc, spread gate, limits

07

Order Placed

Market order via MT5 API

08

Trade Mgmt

Breakeven + trailing stop

Four Trading Strategies

Each strategy runs independently on every M15 candle close and casts a weighted vote: BUY, SELL, or NONE.

EMA Crossover
Trending
Fast EMA20 periods (α = 0.0952)
Slow EMA50 periods (α = 0.0385)
Applied toClose price
ConfidenceFixed 65%
BUY — golden cross (EMA20 above EMA50)
SELL — death cross (EMA20 below EMA50)
RSI Reversal
Ranging
RSI typeWilder's Smoothed RSI
Period14 (α = 1/14)
Oversoldbelow 30
Overboughtabove 70
ConfidenceScales with depth from threshold
BUY — RSI exits oversold (crosses back above 30)
SELL — RSI exits overbought (crosses back below 70)
MACD Crossover
Trending
Fast EMA12 periods
Slow EMA26 periods
Signal EMA9 periods (of MACD line)
MACD lineEMA(12) − EMA(26)
ConfidenceScales with histogram size at cross
BUY — MACD crosses above signal (histogram positive)
SELL — MACD crosses below signal (histogram negative)
Donchian Breakout
Trending / Volatile
Channel period20 candles
Upper bandHighest High of prior 20 bars
Lower bandLowest Low of prior 20 bars
Trigger ruleFirst bar to close beyond band only
ConfidenceScales with distance beyond channel
BUY — candle closes above 20-bar upper band
SELL — candle closes below 20-bar lower band
Min Score
0.55
Below this → no trade, regardless of direction
Min Agreeing
1
At least one strategy must back the winning side
Vote Weights
1.0 each
All four strategies weighted equally
Cooldown
300 s
Per-symbol lockout after any trade decision

Market Regime Filter

After the signal engine votes, an AI overlay classifies the current market using ADX, ATR%, and relative volume. It can only reduce or veto — never inflate a signal.

RegimeTrigger ConditionThresholdEffect on Trades
TRENDING ADX (14-period Wilder's) ADX ≥ 25 Favours EMA_Cross, MACD_Cross, Breakout. No confidence penalty.
RANGING ADX (14-period Wilder's) ADX < 20 Favours RSI_Reversal. Trend strategies signal outside preferred regime.
VOLATILE ATR(14) as % of price ATR% ≥ 0.25% −30% confidence multiplier (×0.70). Favours Breakout; all others dampened.
QUIET Volume ratio (current ÷ 20-bar avg) ratio < 0.70 −20% confidence multiplier (×0.80). Low participation — all signals dampened.
Veto threshold: If the regime-adjusted confidence falls below 0.40, the trade is vetoed entirely — regardless of what the strategies voted.

Position Sizing & Trade Construction

Every position is sized from equity, not fixed lots. Stop and take-profit are derived from live volatility via ATR, not fixed pips.

// Stop Loss
SL_distance = ATR(14) × 1.5
BUY → stop = entry − SL_distance
SELL → stop = entry + SL_distance

// Take Profit (2:1 reward-to-risk)
TP_distance = SL_distance × 2.0
BUY → TP = entry + TP_distance
SELL → TP = entry − TP_distance

// Lot sizing (fixed fractional)
risk_amount = equity × 0.01 // 1% of equity
lots = risk_amount ÷ (SL_distance ÷ point × point_value)

Position Parameters

Risk per trade1.0% of equity
ATR period14 (Wilder's smoothing)
SL multiplierATR × 1.5
TP ratio2:1 (TP = 2 × SL distance)
Max spread30 points — skip if wider

Trade Management

Breakeven triggerAt +1R profit (1× risk)
Breakeven actionSL moves to entry price
Trailing stopATR(14) × 2.0
Trail directionOnly tightens, never widens
Monitoring cycleEvery 15 seconds

Hard Safety Limits

Enforced at the portfolio layer, before any order reaches the broker. These gates cannot be overridden by strategy signals.

Max Open Positions
5
Total across all symbols simultaneously
Per Symbol
1
Only one open position per instrument
Daily Loss Limit
3%
Trading halts for the day if equity drops 3% intraday
Drawdown Kill Switch
15%
Hard stop — all trading ceases, positions closed
Correlation Threshold
0.85
Blocks correlated entries (GBPUSD BUY if EURUSD already long)
Portfolio Risk Cap
5%
Sum of all open-trade risk as % of equity
Static correlation override: EURUSD and GBPUSD are treated as correlated at 0.90 — same-direction positions on both are blocked.

Visibility & Alerts

Every decision is logged, every trade is alerted, every anomaly is caught — in real time.

📊

Live Dashboard

FastAPI web dashboard showing open positions, equity curve, daily P&L, and bot health status.

http://localhost:8000
📱

Telegram Bot

Real-time trade alerts and remote control commands. Notifies on every open/close; controllable from your phone.

/status /positions /pause /resume /closeall
📁

Structured Logs

Three rotating log files, separated by purpose. Searchable and persistent across restarts.

activity.log trades.log errors.log
📈

Equity Curve

Equity sampled and stored across sessions. Visualised in the dashboard. Up to 5,000 sample points retained — persistent across restarts.

Markets & Timeframes

Currently live on four instruments. Any MT5 symbol can be added — broker suffix variants (EURUSD.m, XAUUSD…) are auto-resolved transparently.

EURUSD

Euro / US Dollar  ·  Most liquid FX pair

M15H1Forex

GBPUSD

British Pound / US Dollar  ·  Correlated with EURUSD

M15H1Forex

XAUUSD

Gold / US Dollar  ·  Point = 0.01 · Verified live

M15H1Metal

XAGUSD

Silver / US Dollar  ·  Point = 0.001 · 5000 oz contract

M15H1Metal
Session filter: Trading is only allowed during active sessions — Tokyo (00:00–09:00 UTC), London (07:00–16:00 UTC), New York (12:00–21:00 UTC). No trades are placed on weekends or outside all three sessions.

Multi-Client Rental Portal

A complete onboarding-to-trading pipeline for managed client accounts. Each client runs in an isolated process on the operator's server, with credentials encrypted at rest.

Revenue Model

10% of realised profit per client. No upfront fee — clients only pay when the bot is profitable.

Credential Security

MT5 passwords encrypted with Fernet (AES-128-CBC) and never written to disk in plaintext. Dashboard passwords hashed with scrypt.

Process Isolation

Each client runs as its own Python subprocess with a dedicated log file, state database, and dashboard port. One client crashing does not affect others.

Fleet Auto-Restart

On portal reboot, all previously-running clients are automatically relaunched. No manual intervention needed after a server restart.

Per-Client Risk Settings

Each client can specify their own symbols, timeframes, and risk percentage at onboarding. Settings stored in an encrypted SQLite database.

Telegram for Clients

Client bots send trade alerts to the client's own Telegram chat. Falls back to operator notifications if client hasn't set up Telegram.

Built With

Python 3.13 MetaTrader5 API FastAPI pandas numpy SQLite (WAL) python-telegram-bot cryptography (Fernet) pytest — 187 tests uvicorn Windows / MT5 terminal
10% of profit — no upfront fee

Interested in running the bot on your account?

The bot runs on your own MetaTrader 5 account. You keep full control of your funds — I take 10% of realised profit only when the bot is profitable.

Request Bot Access ← Back to Portfolio

⚠️ Trading bots are for personal research and automation only. Not financial advice. Past performance does not guarantee future results. Consult a licensed financial advisor.