Abhi-AlgoForge Back home

MT5 Renko Gold Bridge

A Renko + SuperTrend execution bridge for MetaTrader 5 — from TradingView alert to broker-validated pending orders on gold.

Client engagement — source code stays private. Shown: architecture, flows and UI.

This system trades gold (XAUUSD) on a Renko-brick + SuperTrend strategy through MetaTrader 5. It began as a classic webhook bridge: a custom Pine Script indicator fires a TradingView alert on every confirmed Renko brick close, the JSON lands on a tunneled webhook server, and the signal becomes MT5 pending stop orders — entry one brick out, stop one brick against, target one brick in favor.

Then it outgrew TradingView entirely. The production line streams raw ticks straight from the MT5 terminal, rebuilds Renko bricks in-process with a custom engine that matches TradingView's semantics exactly — two-brick reversals, wick computation — and computes SuperTrend itself on a 0.2-second loop. The design is symbol-agnostic; the same engine was later pointed at BTCUSD unchanged.

Execution is broker-aware end to end: every price is clamped against the broker's minimum stop and freeze distances, normalized to symbol digits, and sanity-checked for ordering before it's sent. Lot size adapts to realized results — each closed trade's P&L is read back from the broker's deal history and drives a nine-step sizing ladder that resets after wins.

Delivery matched the client, not the developer: the whole bot ships as a single Windows executable with a one-click launcher that opens the tunnel and starts trading, plus a live desktop Renko chart for monitoring.

System architecture

The modules that make it up, and how data flows between them.

Signal layer

Pine alert or tick Renko + SuperTrend

Webhook server

Tunneled HTTP · validates alerts

Execution core

MT5 orders · sizing · reconnects

Live chart monitor

Live Renko chart + buy/sell markers

Hover a module to trace what it feeds.

Signal flow

One brick close, end to end — from signal to broker-validated order.

  1. 1

    Signal arrives

    A TradingView alert posts brick + SuperTrend data to the webhook (or the in-process engine closes a new brick); malformed payloads are rejected on the spot.

  2. 2

    Duplicate-flip check

    If the brick direction hasn't changed since the last signal, it's ignored — duplicate alerts can never double-trade.

  3. 3

    SuperTrend validation

    Setup confirmed

    SuperTrend opposes the brick run (anticipating the reversal) and the projected entry clears the SuperTrend band — proceed.

    Disagreement

    The trend or the projected band says no — any pending order is cancelled and the engine resets to wait.

  4. 4

    Adaptive lot sizing

    The last closed trade's realized P&L is read from the broker's deal history — distinguishing stop, target and manual exits — and updates a nine-step sizing ladder that resets after wins.

  5. 5

    Stale-order cleanup

    Any existing pending order is verified still live at the broker, then cancelled before the new one goes out.

  6. 6

    Broker-aware pricing

    Entry, stop and target are computed brick-spaced, clamped against the broker's stop and freeze distances, normalized to symbol digits and ordering-checked.

  7. 7

    Order send

    Accepted

    The pending stop order rests at the broker awaiting its fill.

    Rejected

    The return code is logged with full context and the ticket state cleared — never a silent failure.

  8. 8

    Reversal square-off

    When SuperTrend flips against an open position, everything is market-closed with escalating slippage tolerances on retry, then the reverse order is placed.

Engineering highlights

The details that keep it alive with real money on the line.

Tick-perfect Renko engine

A custom in-process Renko builder matching TradingView semantics — two-brick reversal rule, wick computation — fed by gap-safe tick ingestion with millisecond-cursor pagination.

Broker-constraint pricing

Stop and freeze level clamping, digit normalization and order-shape sanity checks on every price before it's sent — rejections engineered away.

P&L-adaptive sizing

Position size is driven by realized results pulled from deal history, not guesses — the ladder distinguishes how each trade actually ended.

Restart continuity

Brick history persists across restarts and the MT5 connection retries in a loop — the engine picks up exactly where it left off.

Crash-proof state

Pending tickets are verified against the broker before every action, and duplicate-signal suppression keeps repeated alerts harmless.

One-click delivery

Packaged as a single Windows executable with a launcher that registers the tunnel and starts everything — the client double-clicks and trades.

Under the hood

The stack, and the system in numbers.

Signals
Pine ScriptTradingView alertsCustom Renko engine
Engine
PythonFlaskMetaTrader5 APIpandas-ta
Monitor
Lightweight Charts (desktop)
Delivery
PyInstaller (.exe)ngrok tunnelWindows VPS
2.8k
Lines of code
6
Versions shipped
0.2s
Tick loop
9
Sizing ladder steps

Need a system like this?

I design and build trading infrastructure end to end — let's talk about yours.