Quantum Bridge Documentation
Dashboard Open terminal
Quantum Bridge docs

Connect TradingView to MetaTrader — simply

Quantum Bridge moves strategy signals from TradingView into MT4/MT5. TradingView decides when and what; the EA handles lots, risk, and execution. One webhook with your API key — no keys inside your Pine code.

Quick start

Four steps. Simple by design.

  1. Create a Quantum Bridge account and open the dashboard. Copy your API key from Settings → API keys.
  2. Install the Quantum Bridge EA on MT4 or MT5 (or use a Quantum Bridge hosted terminal). Enable Algo Trading, allow the bridge URLs in Experts options, attach the EA, paste the API key.
  3. Wire alerts with the injector (fast, covers 90%+ of strategies) or paste helpers manually — then create a TradingView alert with alert() function calls only and your webhook URL.
  4. Use this test script. Confirm the fill in MetaTrader and in the dashboard signal log.
Test strategy — Basic Buy Sell Alternating
//@version=6
strategy("Basic Buy Sell Alternating", overlay=true)

// === Quantum Bridge Helpers (v5/v6) ===
m(action, tradeId, entry, sl, tp) =>
    alert(str.format("{0}|{1}|{2}|{3}|{4}", action, tradeId, entry, sl, tp), freq=alert.freq_once_per_bar_close)
m2(action, tradeId, stopPrice, limitPrice, sl, tp) =>
    alert(str.format("{0}|{1}|{2}|{3}|{4}|{5}", action, tradeId, stopPrice, limitPrice, sl, tp), freq=alert.freq_once_per_bar_close)
t(tradeId, newSl) => alert(str.format("TRAIL|{0}|{1}", tradeId, newSl), freq=alert.freq_once_per_bar_close)
tp(tradeId, newTp) => alert(str.format("TP|{0}|{1}", tradeId, newTp), freq=alert.freq_once_per_bar_close)
p(tradeId, percent) => alert(str.format("PARTIAL|{0}|{1}", tradeId, percent), freq=alert.freq_once_per_bar_close)
add(parentId, addNum, sl, tp) => alert(str.format("ADD|{0}'{1}|{2}|{3}", parentId, addNum, sl, tp), freq=alert.freq_once_per_bar_close)
cancel(tradeId) => alert(str.format("CANCEL|{0}", tradeId), freq=alert.freq_once_per_bar_close)
cancelAll() => alert("CANCEL_ALL_PENDING", freq=alert.freq_once_per_bar_close)
closeAllTrades() => alert("CLOSE_ALL", freq=alert.freq_once_per_bar_close)

slPips = input.float(500, "SL (pips)")
tpPips = input.float(1000, "TP (pips)")
pipValue = syminfo.mintick * 10

var bool lastWasBuy = false
var int tradeCount = 0
var string activeTradeId = ""

if barstate.isconfirmed
    float entry = close
    float slDist = slPips * pipValue
    float tpDist = tpPips * pipValue

    if strategy.position_size != 0
        strategy.close_all(comment="Flip close")
        alert(str.format("CLOSE|{0}", activeTradeId), freq=alert.freq_once_per_bar_close)

    if not lastWasBuy
        string tradeId = "Buy_" + str.tostring(tradeCount)
        float buySL = entry - slDist
        float buyTP = entry + tpDist
        m("BUY", tradeId, entry, buySL, buyTP)
        strategy.entry(tradeId, strategy.long, qty=1.0, comment=tradeId)
        strategy.exit("Exit_" + tradeId, from_entry=tradeId, stop=buySL, limit=buyTP)
        activeTradeId := tradeId
        lastWasBuy := true
    else
        string tradeId = "Sell_" + str.tostring(tradeCount)
        float sellSL = entry + slDist
        float sellTP = entry - tpDist
        m("SELL", tradeId, entry, sellSL, sellTP)
        strategy.entry(tradeId, strategy.short, qty=1.0, comment=tradeId)
        strategy.exit("Exit_" + tradeId, from_entry=tradeId, stop=sellSL, limit=sellTP)
        activeTradeId := tradeId
        lastWasBuy := false

    tradeCount := tradeCount + 1
Tip
Test on a demo account first. Attach the EA to the same symbol you alert on in TradingView.
Quantum Bridge

Requirements

What you need before connecting.

ItemDetail
Quantum Bridge accountRegistered user with an API key
MetaTraderMT4 or MT5 from your broker (demo or live)
TradingViewPlan that supports webhook alerts (Essential or higher)
Pine ScriptStrategy on v4 / v5 / v6
PC or VPS or Quantum Bridge built-in MT4/MT5 host terminalTerminal must stay running for the EA to receive signals

Account & API key

Your API key links the EA and the webhook to your account.

  1. Sign in → open Settings.
  2. Copy the key from API keys.
  3. Paste it into the EA inputs.
API key card

In the EA inputs and as api_key on the webhook in TradingView notifications. Your dashboard Settings page shows the exact webhook to copy.

Yes. After regenerate, update the EA and the webhook URL. An invalid key triggers the EA kill switch and detaches it from the chart.

Install the EA (MT4 / MT5)

Put the EA in Experts, allow the bridge hosts, attach to a chart, paste the API key.

Allow WebRequest URLs

In MetaTrader: Tools → Options → Expert Advisors. Enable WebRequest and add:

https://quantumbridge.cloud
https://quantumbridge.cloud/signal

MT5

  1. Download the EA from the dashboard.
  2. File → Open Data Folder → MQL5 → Experts. Copy the EA file(s) here.
  3. Navigator → Expert Advisors → right-click → Refresh.
  4. Enable Algo Trading.
  5. Drag the EA onto a chart. Inputs → paste API key → OK.
  6. Confirm the dashboard shows the account as MetaTrader Live.

MT4

  1. Data folder path is MQL4 → Experts.
  2. Enable AutoTrading / live trading for your build.
  3. Attach EA, paste API key, confirm MetaTrader Live on the dashboard.
Symbol rule
There is no symbol mapping. Trade the same instrument on TradingView and on the chart where the EA is attached. To switch pairs: change the TV alert symbol and move the EA to that chart — seconds, not a mapping table.

EA settings

From Quantum Bridge EA v5.0. Defaults are fine for first tests; change what you understand.

SettingGroupPurpose
API key—Authenticates the terminal to your account
MagicTrade managementIsolates bridge trades from other EAs
Max trades / max pendingTrade managementCaps open positions and pending orders
Close on oppositeTrade managementCloses opposing side before a new entry
Close on signalTrade managementCloses all before a new entry when enabled
Use signal SL / TPTrade managementApplies SL and TP sent from the alert
Slippage / fill type / poll intervalOrder executionExecution tolerance and signal poll rate
Dynamic lot / % risk / initial lot / min–max lotLot sizeHow volume is calculated on the EA side
Enable adds / fixed or % add / max addsAdd to positionScale-in behaviour for ADD signals
Send positions / history / pendingDashboard syncWhat streams to the web dashboard

Many of these can also be updated remotely from the dashboard once the EA has sent its config.

How alerts work

Quantum Bridge does not rewrite your strategy logic. It adds short alert lines next to the actions you already trade — entries, trails, TP changes, partials, cancels, closes. Those alerts reach the EA.

  • Your Pine strategy runs on TradingView as usual.
  • At each action point, a helper fires a pipe-delimited message (e.g. BUY|Long_0|1.1050|1.1000|1.1100).
  • The webhook carries it to Quantum Bridge → your EA mirrors it on the chart symbol.
Golden rule
Entries, exits, indicators, and conditions stay yours. Only alert lines are added. No lots or API keys in the message — the EA owns sizing.

Before and after — the core pattern

Before
strategy.entry(tradeId, strategy.long, comment=tradeId)
After
m("BUY", tradeId, entry, sl, tp)
strategy.entry(tradeId, strategy.long, comment=tradeId)
m("BUY", tradeId, entry, sl, tp)

One line above the entry. Place helpers right after strategy(...) so Pine can see them.

Strategy injector

A powerful automation tool that is continuously updated to support more strategy patterns. It is built to inject alerts correctly on the vast majority of strategies — typically 90%+ of real-world scripts go through cleanly.

Use the injector when you want speed: paste your strategy, run inject, review, and deploy. Prefer manual helpers when you want full hands-on control over every line and ID style. In rare cases — deeply nested SL/TP built after entry, or highly custom multi-trade ID systems — the injector may need a small manual touch. If you cannot resolve it, send the script to Quantum Bridge support for guided wiring.

  • Injector — fastest path for most users; actively improved for edge cases.
  • Manual helpers — full control and personal style; still simple copy-paste.
  • Support — when a complex nested script needs a human pass.

The injector renames or tracks trade IDs where needed so trail, TP, partial, and close alerts stay linked to the right position.

Market, stop & limit orders

m = market, stop, and limit. m2 = stop-limit only. One alert line above the order — same tradeId, SL/TP from your script (or 0.0).

OrderAlertPine
Market buym → BUYstrategy.entry(..., strategy.long)
Market sellm → SELLstrategy.entry(..., strategy.short)
Buy / sell stopm → BUYSTOP / SELLSTOPstrategy.entry(..., stop=...)
Buy / sell limitm → BUYLIMIT / SELLLIMITstrategy.order(..., limit=...)
Buy / sell stop-limitm2 → BUYSTOPLIMIT / SELLSTOPLIMITstop + limit prices

Market buy — no SL/TP

Before
strategy.entry(tradeId, strategy.long, comment=tradeId)
After
m("BUY", tradeId, close, 0.0, 0.0)
strategy.entry(tradeId, strategy.long, comment=tradeId)

0.0 means “not set” — the bridge does not invent defaults.

Market buy — strategy already has SL/TP

Before
strategy.entry(tradeId, strategy.long, comment=tradeId)
After
m("BUY", tradeId, entry, sl, tp)
strategy.entry(tradeId, strategy.long, comment=tradeId)
m("BUY", tradeId, entry, sl, tp)

Buy stop

Before
strategy.entry(tradeId, strategy.long, stop=entry)
After
m("BUYSTOP", tradeId, entry, sl, tp)
strategy.entry(tradeId, strategy.long, stop=entry)

Buy stop-limit m2

m covers market, stop, and limit. m2 is for stop-limit only (stop price + limit price).

Before
strategy.order(tradeId, strategy.long, stop=stopPrice, limit=limitPrice)
After
m2("BUYSTOPLIMIT", tradeId, stopPrice, limitPrice, sl, tp)
strategy.order(tradeId, strategy.long, stop=stopPrice, limit=limitPrice)
m2("BUYSTOPLIMIT", tradeId, stopPrice, limitPrice, sl, tp)
Before
strategy.order(tradeId, strategy.short, stop=stopPrice, limit=limitPrice)
After
m2("SELLSTOPLIMIT", tradeId, stopPrice, limitPrice, sl, tp)
strategy.order(tradeId, strategy.short, stop=stopPrice, limit=limitPrice)

Cancel pending

Before
strategy.cancel(tradeId)
After
cancel(tradeId)
strategy.cancel(tradeId)
No auto-close
If your strategy never closes a position, Quantum Bridge does not invent a close. It only mirrors what you already do.

Trailing SL & TP modification

When your strategy moves stop or target after entry, add t() or tp() at the same place the value changes.

Trailing stop

Before
newSL = close + trailDist
strategy.exit("Exit", from_entry=tradeId, stop=newSL)
After
newSL = close + trailDist
t(tradeId, newSL)
strategy.exit("Exit", from_entry=tradeId, stop=newSL)
t(tradeId, newSL)

Take-profit modification

Before
newTP = close + tpDist
strategy.exit("Exit", from_entry=tradeId, limit=newTP)
After
newTP = close + tpDist
tp(tradeId, newTP)
strategy.exit("Exit", from_entry=tradeId, limit=newTP)
tp(tradeId, newTP)

Both changing in one block? Fire t(...) and tp(...) together.

Trail that recalculates every bar

Only alert when the value actually moves — avoid spamming identical trails.

Before
trailing_sl := max(low - sl_val, trailing_sl[1])
After
trailing_sl := max(low - sl_val, trailing_sl[1])
if trailing_sl != trailing_sl[1]
    t(tradeId, trailing_sl)

Partial close, add & close

Only when your strategy already does these actions.

Partial close

Before
if partialCondition
    strategy.close(tradeId, qty_percent=50)
After
if partialCondition
    p(tradeId, 50)
    strategy.close(tradeId, qty_percent=50)
p(tradeId, 50)

Add to position

Add IDs use parentId'addNumber (example ZS_0'1).

Before
strategy.entry(tradeId, strategy.long)
After
add(parentId, 1, sl, tp)
strategy.entry(tradeId, strategy.long)
Adds are independent
Each add can have its own trail, TP, partial, and close — keyed on the full add ID. Closing the parent closes linked adds on the EA.

Close position

Before
strategy.close(tradeId)
After
alert(str.format("CLOSE|{0}", tradeId),
    freq=alert.freq_once_per_bar_close)
strategy.close(tradeId)

Trade IDs

One ID per trade. Use the same tradeId on the alert and on the strategy call.

Matching rule
Entry alert ID and exit / trail / TP / partial / close must use the same tradeId.

Simple

m("BUY", tradeId, entry, sl, tp)
strategy.entry(tradeId, strategy.long, comment=tradeId)
Tip
If every trade uses the same fixed string (e.g. only "Long"), IDs can collide. Use a unique tradeId per trade when you have more than one open at a time. The injector can help with that automatically.

Helper functions (copy-paste)

Paste under strategy(...). Use the set that matches your Pine version.

Pine v5 & v6
// === Quantum Bridge Helpers (v5/v6) ===
m(action, tradeId, entry, sl, tp) => alert(str.format("{0}|{1}|{2}|{3}|{4}", action, tradeId, entry, sl, tp), freq=alert.freq_once_per_bar_close)
m2(action, tradeId, stopPrice, limitPrice, sl, tp) => alert(str.format("{0}|{1}|{2}|{3}|{4}|{5}", action, tradeId, stopPrice, limitPrice, sl, tp), freq=alert.freq_once_per_bar_close)
t(tradeId, newSl) => alert(str.format("TRAIL|{0}|{1}", tradeId, newSl), freq=alert.freq_once_per_bar_close)
tp(tradeId, newTp) => alert(str.format("TP|{0}|{1}", tradeId, newTp), freq=alert.freq_once_per_bar_close)
p(tradeId, percent) => alert(str.format("PARTIAL|{0}|{1}", tradeId, percent), freq=alert.freq_once_per_bar_close)
add(parentId, addNum, sl, tp) => alert(str.format("ADD|{0}'{1}|{2}|{3}", parentId, addNum, sl, tp), freq=alert.freq_once_per_bar_close)
cancel(tradeId) => alert(str.format("CANCEL|{0}", tradeId), freq=alert.freq_once_per_bar_close)
cancelAll() => alert("CANCEL_ALL_PENDING", freq=alert.freq_once_per_bar_close)
closeAllTrades() => alert("CLOSE_ALL", freq=alert.freq_once_per_bar_close)
Pine v4
// === Quantum Bridge Helpers (v4) ===
m(action, tradeId, entry, sl, tp) => alert(str.format("{0}|{1}|{2}|{3}|{4}", action, tradeId, entry, sl, tp), alert.freq_once_per_bar_close)
m2(action, tradeId, stopPrice, limitPrice, sl, tp) => alert(str.format("{0}|{1}|{2}|{3}|{4}|{5}", action, tradeId, stopPrice, limitPrice, sl, tp), alert.freq_once_per_bar_close)
t(tradeId, newSl) => alert(str.format("TRAIL|{0}|{1}", tradeId, newSl), alert.freq_once_per_bar_close)
tp(tradeId, newTp) => alert(str.format("TP|{0}|{1}", tradeId, newTp), alert.freq_once_per_bar_close)
p(tradeId, percent) => alert(str.format("PARTIAL|{0}|{1}", tradeId, percent), alert.freq_once_per_bar_close)
add(parentId, addNum, sl, tp) => alert(str.format("ADD|{0}'{1}|{2}|{3}", parentId, addNum, sl, tp), alert.freq_once_per_bar_close)
cancel(tradeId) => alert(str.format("CANCEL|{0}", tradeId), alert.freq_once_per_bar_close)
cancelAll() => alert("CANCEL_ALL_PENDING", alert.freq_once_per_bar_close)
closeAllTrades() => alert("CLOSE_ALL", alert.freq_once_per_bar_close)
Version matters
v5/v6 use freq=alert.freq_once_per_bar_close. v4 uses alert.freq_once_per_bar_close without the freq= name. Do not mix sets.

Create the TradingView alert

After helpers (or inject), create one alert that listens for function calls.

  1. Add the strategy to the chart (symbol and timeframe you want to trade).
  2. Create alert → Condition: your strategy → alert() function calls only.
  3. Notifications → enable Webhook URL → paste the URL from Settings (includes your API key).
  4. Alert name can be anything normal — payloads come from the script helpers.
  5. Create the alert.

The timeframe on the chart is the timeframe the alerts use.

Quantum Bridge

Webhook URL

Set once in TradingView. Switching symbols does not require changing Pine — only the alert chart and the EA chart.

https://quantumbridge.cloud/webhook?api_key=YOUR_API_KEY
Webhook / API settings
Security
Copy the full URL from Settings. Do not publish real keys in screenshots or public scripts.

Alert syntax reference

Pipe-separated. No symbol in the message — the EA trades the chart it is attached to.

HelperShapeMeaning
mBUY|id|entry|sl|tpMarket / stop / limit entry
m2…stop|limit|sl|tpStop-limit
tTRAIL|id|newSlUpdate stop
tpTP|id|newTpUpdate take-profit
pPARTIAL|id|%Partial close
addADD|parent'n|sl|tpAdd to position
cancel / cancelAllCANCEL…Pending cancel
closeAllTradesCLOSE_ALLClose all bridge positions
Choose your path
Injector — go-to for fast setup on the large majority of strategies; kept current as new patterns appear.
Manual helpers — full control when you want every line written your way.
Support — rare nested / multi-ID cases where you want a guided finish.

Stops, targets & trailing

Send real price levels from Pine. The EA applies them when Use Signal SL / TP is enabled.

  • Put SL and TP in m(...) / m2(...) at entry.
  • Update later with t(id, newSl) and tp(id, newTp).
  • Keep the same trade id so the EA finds the position.

Lot sizing & risk

Sizing lives on the EA — not in the alert.

  • Fixed initial lot, dynamic lot steps, or % risk modes (see EA inputs).
  • Min / max lot clamps protect the account.
  • Adds use fixed lot or % of current volume when enabled.

Symbols & brokers

No mapping layer by design.

  • Alert on XAUUSD in TradingView → run the EA on XAUUSD in MetaTrader.
  • Need another pair mid-session: change the alert’s chart and the EA’s chart — done.
  • Works with major MT4/MT5 brokers; always validate on demo for your server’s symbol names.

Troubleshooting

Check API key, WebRequest allow-list for both bridge URLs, Algo Trading on, EA still on a chart, and Experts/Journal for errors.

Confirm webhook URL with key, alert condition is alert() function calls only, dashboard signal log received the line, and EA chart symbol matches the alert symbol.

Same trade id on entry and t/tp, Use Signal SL/TP enabled, and signal log shows TRAIL/TP lines.

FAQ

Minimal skill is enough for manual helpers: paste the block and call m("BUY", …) at entries. The injector is optional. Support can guide complex scripts.

A terminal with the EA must run (your PC, your VPS, or a Quantum Bridge free hosted MT4/MT5 terminal — spin up and leave it 24/7 with no extra cost on the included host).

Yes. Run it through the injector or add helpers yourself, then create an alert on alert() function calls only.

Simplicity. The EA trades the chart it is on. Switch pairs by switching charts — no mapping table to maintain under pressure.

Both are first-class. The injector is a powerful, actively improved tool that handles 90%+ of strategies out of the box. Manual helpers give full line-by-line control. Rare nested or multi-ID edge cases can go to support.

Support

Still stuck after the checks above?

  • Open Support from the dashboard chat.
  • Include: broker + MT build, key prefix only, signal log, Experts text.

Go to dashboard   Back to home