TradinSolutionsEXECUTION LAYER
Start Free Trial →
HOME/BLOG

Notes from building execution infrastructure.

Prop-firm drawdown arithmetic, broker symbol suffixes, contract rolls, and what actually breaks when you copy a trade across five platforms.

← ALL POSTS
Platform Tutorials20 Sept 2026 · 12 min · TradinSolutions

How to Connect TradingView Alerts to a Broker Account

TradingView has no trading API. An alert is a message, not an order — so something has to receive it, decide the size and place the trade. Here is exactly what the message must contain, what happens between it and the fill, and where the arrangement stops.

A strategy has been on the chart for six weeks. It back-tests sensibly, it has been forward-tested on a demo, and the alert condition is exactly right. The alert fires at 03:14, the phone buzzes on a bedside table, and by the time anyone reads it the move is half over. That is the whole problem, and it has nothing to do with the strategy.

The answer, before the detail: TradingView does not place trades. It has no trading API of its own, and an alert is a message rather than an order. What closes the gap is a webhook — the alert posts a small piece of JSON to a URL, and whatever sits at that URL decides what the message means, works out a position size and sends the order to your broker. Everything interesting happens on the receiving side, which is also where every way of getting this wrong lives.

INFO

Quick answer. Add an alert to your indicator or strategy, put a webhook URL in the alert's webhook field and a line of JSON in its message box. The minimum message is an instrument and a direction: {"symbol":"{{ticker}}","side":"buy"}. Stop, target and entry price are optional fields. To get out again, send {"action":"close","symbol":"{{ticker}}"}. The receiving service decides the size from your account, not from anything in the alert.

What a TradingView alert actually is

An alert is a rule plus a delivery method. The rule is Pine — a crossing, a condition inside a strategy, an order fill. The delivery method is a pop-up, a sound, an email, a push to the mobile app, or an HTTP POST to a URL you supply. Only the last can be acted on by software, and what it sends is narrower than people assume: TradingView posts the contents of the alert's message box, verbatim, as the body of the request. No description of your strategy, your position or your intent travels with it. If the message box says "long", the word "long" is what arrives.

So the message box is not a note to yourself. It is the API call.

The placeholders are what make this general. Pine exposes doubled-brace placeholders that TradingView substitutes as the alert fires — the chart's ticker, the current close, a strategy's order details — so one alert follows you between instruments instead of being hard-coded to the chart you wrote it on.

WARNING

TradingView's own broker integrations, where they exist, are a separate product from alerts and are not what a webhook does. A webhook sends a message to a third party; it does not route an order through TradingView.

Three pieces make the arrangement: the alert, a webhook URL unique to one setup and carrying its own token, and the account the order is finally sent to. The URL is the credential — no login passes between the two services — so it should be treated like a password and rotated if it is ever pasted somewhere public.

What goes in the message box

Here is the entry message, whole:

json
{"symbol":"{{ticker}}","side":"buy","entry":{{close}},"sl":2375,"tp":[2390,2400]}

The doubled braces are TradingView's own placeholders; it fills them in at fire time. Field by field:

FieldRequiredWhat it does
~symbol~yesthe instrument. ~{{ticker}}~ makes the alert portable across charts
~side~yes~buy~ or ~sell~. Nothing else is accepted
~orderType~no~market~ (the default), ~limit~ or ~stop~
~entry~for limit and stopthe price to work the order at
~sl~nothe stop level. Left out, the instance's own stop setting applies
~tp~noone target, or a list of them

Two things follow from that table that people are usually surprised by.

There is no size field. Deliberately. A size written into an alert is a number from the chart you wrote it on, and it means something different on every account it reaches. Size is worked out on arrival, from the receiving account's own balance and the distance to the stop.

Stop and target are optional, not implied. An alert without sl does not mean "no stop"; it means "use the stop rule I configured for this instance". If you configured nothing, nothing is attached, and that is a decision to make consciously rather than discover.

Getting out again

An entry alert is half a strategy. The exit is the half people leave until after the first live trade, and the half that costs money.

json
{"action":"close","symbol":"{{ticker}}"}
{"action":"close"}

The first closes what is open on that instrument. The second, with no instrument at all, closes everything that setup is holding — the flatten condition a strategy usually wants at the session close. Three properties are worth knowing before you rely on one.

It carries no direction and no levels. You are not sending a sell to offset a buy; you are asking to be flat. A close alert that had to name a side would be wrong half the time.

It cancels working orders as well as closing positions. If a limit entry is still resting unfilled on the same instrument, it is cancelled too. Standing down has to mean standing down — leaving a working order alive after you have asked to be flat is how a position appears an hour later that nobody is expecting.

The instrument is matched on the root. On a futures chart the name on the chart and the name of the contract you hold are rarely the same string. A continuous chart and a dated December or March contract all resolve to one root, so an alert fired from the continuous chart closes the dated position it actually opened. A different root never matches, deliberately: a close acts on real positions, and "near enough" would be the wrong one.

What happens between the alert and the order

This is the part a vendor's marketing page usually skips. The sequence, in order:

text
1  TradingView posts the alert body to the webhook URL
2  the token in the URL is verified                      reject → 401, nothing happens
3  the message is read into instrument / side / levels   unreadable → 400
4  your symbol whitelist                                 not listed → skipped, logged
5  your session window                                   outside it → skipped, logged
6  your duplicate-signal window                          repeat → skipped, logged
7  your daily trade cap                                  reached → skipped, logged
8  the account can execute right now                     cannot → skipped, logged
9  size from balance and stop distance                   below minimum → refused, logged
10 stop and target sanity check                          on the wrong side → refused
11 the order is sent

Every one of those refusals is written into the instance's log with the reason beside it — the property to insist on from any service in this position, because an alert that silently did nothing is indistinguishable from one that never fired, and you will not find out which until the account is down.

Step 10 earns its place. A stop above the entry on a buy, or a target below it, is the commonest mistake in a hand-written alert message. Some platforms reject it; others accept it and fill the stop at once, closing the trade on the spread before anyone sees it.

Sizing: the field the alert does not get to set

The size is computed on arrival from three things: the receiving account's balance, the risk percentage you set for that instance, and the distance between the fill and the stop. The last is easy to get wrong in theory and expensive in practice. The alert's entry is a reference level — where the strategy thought it was getting in. The fill is where the order actually went on. On a quiet chart they are the same; on a release they are not.

text
signal entry      2380      stop 2375      intended distance 5 points
actual fill       2383                     real distance     8 points

sizing from the signal's entry  →  risk is 1.6× what was configured
sizing from the actual fill     →  risk is what was configured

Sizing from the fill rather than from the level in the message is what keeps a fast market from quietly multiplying your risk. It is also why a size baked into the alert message is worse than no size at all.

One more refusal belongs here. If the computed size comes out below the broker's minimum — a tight stop on a small account, most often — the correct behaviour is to skip the trade and say so, not to round up. Rounding up opens a position risking more than the figure you configured, sometimes by a large multiple on a small account, and nobody chose that.

Limit and stop entries

A strategy that says "buy the retest at 2380" is not the same strategy as "buy at whatever is trading when the alert lands". Adding "orderType":"limit" with an entry price places a real working order and leaves it working until it fills or until the expiry you set runs out.

json
{"symbol":"{{ticker}}","side":"buy","orderType":"limit","entry":2380,"sl":2375}

A working order is not a position. Nothing is at risk until one fills, so it should not appear in an open-position count, and one the market never reaches should not consume a daily trade cap — a trade that did not happen is not one of the day's trades. Sizing is the one case here where the level in the message is the honest denominator, because that is the price it will fill at.

Futures charts need one more rule

A futures destination needs one extra piece: a mapping rule saying which contract the alert's instrument means. Futures accounts do not trade instrument names, they trade dated contracts, and a TradingView futures chart is frequently a continuous series rather than a month. A rule resolves the root to the front month and re-checks it, so the mapping keeps working through each quarterly roll instead of pointing at an expired contract eight weeks later.

An alert for an instrument with no mapping rule is held, not guessed at. Guessing a contract month risks trading an expired or wrong-month contract, which is worse than a missed trade. Write the rule before you arm the alert.

The mechanics of that — micro and mini ratios, rollover, netting — are the subject of copying signals to a futures account, and they apply identically whether the signal came from a channel or from a chart.

What this arrangement does not do

Worth stating, because the gap between what people assume and what is true is where the support tickets come from.

  • One alert posts to one URL, so a webhook setup fires into one execution account rather than fanning out. The same chart signal on four accounts is a different arrangement: one account receives the alert, and a copier sits behind it.
  • Webhook notifications are a TradingView plan feature, on the paid plans rather than the free one. That is theirs to decide and theirs to change, so check it on their site before you build a workflow on it. We are not affiliated with TradingView, not partnered with them, and make no promise about how their alerts will behave in future.
  • An alert that never fires cannot be executed. Repainting indicators, alerts set to fire once, charts on the wrong timeframe and alerts that have expired are all still yours to watch, and none of them are visible from the receiving side.
  • This is not a replacement for a VPS if you also run Expert Advisors. It removes the need for one on this path, because the receiving relay is hosted and nothing depends on a machine of yours staying awake. An EA you run locally still needs somewhere to run.

Frequently asked questions

Can I automate a TradingView strategy without a VPS?

On this path, yes. The alert is sent by TradingView's own servers and received by a hosted service, so no machine of yours has to stay switched on. The reason people historically rented a Windows box was to keep a terminal and an Expert Advisor running, and a webhook needs neither. If you also run local EAs, that requirement is unchanged.

Can an alert close a position as well as open one?

Yes. A close message names no direction and carries no levels, which is what makes it safe to fire from a strategy's exit condition. It closes what is open on that instrument and cancels any entry order still working for it. Sent with no instrument at all, it flattens everything that setup is holding.

Does it work with Pine Script alerts from a strategy, not just an indicator?

Yes. An alert on a strategy's order fill and one on an indicator's condition arrive the same way — a POST with your message box as the body. What differs is when they fire, not what they send.

Which broker platforms can an alert actually trade on?

MT4, MT5, cTrader, Tradovate and NinjaTrader, with limit and stop entries on all five. A futures destination needs a contract mapping rule first. A MetaTrader destination needs nothing beyond the linked account, because instrument names are matched against that broker's own symbol list, suffixes and all.

Is the webhook URL a security risk?

It is a secret and should be treated like one. Anyone holding it can post a message to it, so it should never appear in a screenshot, a shared Pine script or a support thread. It is not a broker login and cannot move money — a trading credential places orders, it does not withdraw — but it can place a trade, which is reason enough to rotate it if it leaks.

Where this fits

Choosing between a chart alert and a signal channel as the source is really a choice between two machines, and the difference between a trade copier and a signal copier decides which one you want. The security model behind each way of linking an account — OAuth, stored credentials, and a webhook URL like this one — is set out in how trading accounts get linked. And if the question underneath all of it is how long the chain takes, what copier latency really measures covers which segments anyone can measure.

NEXT