MQL5Algorithmic TradingAutomation

I Built an Algorithmic Trading Bot in MQL5: Architecture, Strategy & Lessons

Breaking down NovaBracket — a swing breakout bracket strategy with trailing stops, risk management, and 24/7 VPS execution.

Mar 1, 2026
15 min read
I Built an Algorithmic Trading Bot in MQL5: Architecture, Strategy & Lessons

Why I Built a Trading Bot (And Why No Martingale)

Most retail trading bots use Martingale — doubling down after losses to eventually recover. It works until it doesn't, and when it fails, it wipes your entire account. I wanted to build something that respects risk management fundamentals.

NovaBracket is a swing breakout bracket strategy for MetaTrader 5. It identifies swing high/low breakout levels, places bracket orders (entry + stop loss + take profit), and manages positions with trailing stops.

The Strategy: Swing High/Low Breakout Brackets

The core logic:

  1. Identify swing highs and lows over the last N candles
  2. Place pending orders at breakout levels with predefined risk
  3. Bracket management: Each entry has a hard stop loss AND a take profit
  4. Trailing stop: Once in profit, the stop loss trails to lock in gains
// Simplified swing detection
double FindSwingHigh(int lookback) {
    double high = 0;
    for(int i = 1; i <= lookback; i++) {
        if(iHigh(_Symbol, PERIOD_H4, i) > high)
            high = iHigh(_Symbol, PERIOD_H4, i);
    }
    return high;
}

Risk Management: The Non-Negotiables

Every trade follows strict rules:

  • Max 2% risk per trade — auto-calculated lot sizing based on account balance and stop distance
  • Spread filter — no entries when spread exceeds 2x average (avoids news events)
  • Max concurrent positions: 3
  • Daily loss limit: 5% of account → EA stops trading for the day
  • No martingale, no grid, no averaging down

Deploying on a VPS for 24/7 Execution

The bot runs on a Windows VPS (Contabo, ~$8/month) with MetaTrader 5:

  • Auto-restart on crash via Windows Task Scheduler
  • Telegram notifications for every trade entry/exit
  • Weekly performance reports sent automatically

Backtesting Results

| Metric | Value | |--------|-------| | Backtest period | 2023-2025 | | Total trades | 847 | | Win rate | 42% | | Profit factor | 1.68 | | Max drawdown | 12.3% | | Sharpe ratio | 1.4 |

A 42% win rate might seem low, but with a 1:2.5 risk-reward ratio, the math works. You lose more often but win bigger when you win.

What's Next

  • Multi-timeframe confirmation (H4 structure + H1 entry)
  • ML-based regime detection (trending vs. ranging markets)
  • Portfolio of uncorrelated strategies across different pairs

Need custom algorithm development? I build automation that runs 24/7. Book a call.

Want more like this?

Get the free toolkit + occasional tips on React Native, Next.js, and AI.

No spam. Unsubscribe anytime.