Automate

What to put in a TradingView alert message

A TradingView alert message is just text, and if that text is valid JSON, TradingView posts it with an application/json content type. Everything below is about what to put in it — including the two fields that turn "do this" into "be this", which is the single best protection against an alert that fires twice.

Checked against Tradeus on 14 September 2026.

Before you start

  • A TradingView account with 2-factor authentication enabled.
  • A Tradeus strategy, which is where the passphrase comes from.
  • A Pine strategy or indicator on the chart you want to alert from.

The numbers

Time TradingView waits for the receiver
3 seconds, then the request is cancelled
Ports it will post to
80 and 443 only
IPv6
Not supported for webhooks
Account requirement
2-factor authentication must be enabled
Content type when the message is valid JSON
application/json
Content type otherwise
text/plain
Required fields
passphrase and ticker
Accepted actions
buy, sell, long, short, exit, close, flat, cancel, add
Repeated id
Treated as the same signal — a retry does not trade twice

Step by step

What to do, in order.

  1. 1

    Copy the message off the strategy, not out of a guide

    Each strategy displays a ready-made alert message with its own passphrase already filled in. Copy that one. Every example published anywhere, including the one below, carries a placeholder where the passphrase goes, and pasting a placeholder produces an invalid passphrase rejection that looks like a broken integration.

  2. 2

    Use the strategy template if your Pine script is a strategy

    A strategy alert can read TradingView's strategy placeholders, and the template uses them: {{strategy.order.action}} for the direction, {{strategy.order.contracts}} for the size, and {{strategy.market_position}} with {{strategy.market_position_size}} for the position you should end up holding. All four are documented by TradingView on the strategy-alerts page linked below.

  3. 3

    Use the indicator template if it is an indicator

    An indicator alert has no strategy placeholders to read, so the direction is written literally — "action": "buy" — and one alert is created per direction. Everything else is the same. The alternative is an alert() call inside the script with the whole JSON built in Pine, which is the more flexible route and the harder one to debug.

  4. 4

    Keep position_size and position if you write your own message

    A normal alert says DO THIS: buy two. An alert carrying position_size together with position says BE THIS: end up long two. Tradeus then compares that against what the account actually holds and sends only the difference — so a duplicate alert changes nothing instead of doubling you up. If you write your own message and keep only two fields from the template, keep these.

  5. 5

    Add an id so a retry cannot trade twice

    Repeated ids are treated as the same signal. The template builds one from {{timenow}} and {{strategy.order.id}}, which is unique per order and stable across a retry. It is optional and it is the cheapest idempotency you will ever get.

What goes wrong

Named after the message you will see.

Each of these is a line from the event log or from TradingView, written as it appears — because that is the string you will paste into a search box at the moment you need this page.

“payload invalid”

A field is missing or holds a value outside the allowed list, and the message names the field. The usual cause is a Pine placeholder that resolved to an empty string because the alert was created from an indicator while the message was written for a strategy.

The message is not valid JSON

TradingView sends application/json only when the message parses as JSON; otherwise it sends text/plain. A trailing comma or a smart quote pasted from a document is enough to change which of those happens.

A strategy that fires twice doubles the position

Without position_size and position, two identical alerts are two orders. With them, the second alert asks for a position the account already holds and is recorded as already at target position — which is the correct outcome and reads like a failure until you know it.

“no subscription” — the alert arrived and nothing traded

The strategy received the signal and no account was following it. Open the strategy, add the account, and re-send. This accounts for more first-run confusion than every other cause put together, because the webhook itself answers perfectly well.

“invalid passphrase” after everything worked yesterday

Somebody pressed New passphrase. The old one stops working immediately and the alert in TradingView still carries it. Copy the current message off the strategy into the alert again.

Questions

Asked before buying, answered either way.

What is the minimum alert message that works?

A passphrase, a ticker and an action — for example {"passphrase":"…","ticker":"{{ticker}}","action":"buy"}. Everything else is optional. Quantity, stop loss and the position fields each unlock something, but nothing else is required for an order to be placed.

What is the difference between quantity and position_size?

quantity is an instruction — trade this many contracts. position_size is a destination — end up holding this many. With a destination, a duplicate alert is a no-op, because the account is already where the alert asked it to be.

Can I use alert() inside Pine instead of the alert dialog?

Yes. Building the JSON inside the script and firing it with alert() gives you dynamic values the dialog cannot produce. It is also harder to debug, because a malformed string now comes from your code rather than from a box you can read. Get the dialog version working first.

Are sl and tp required for risk-based sizing?

sl is. Dollar-risk and percent-risk sizing divide your risk budget by the stop distance, and with no sl in the alert there is no distance to divide by. Without it, use signal or fixed sizing instead.

In the handbook

The reference pages behind the steps above — one thing each, in full.

Sources

Every claim above about somebody else's product, linked to the page it was read from. If one of them no longer says what this page says, this page is wrong and we want to know: tell us.

Checked against the live product on 14 September 2026. Broker screens and TradingView's own limits change; a step that no longer matches what you see is a step we need to fix.

Next

The neighbouring jobs.

Weighing this against another tool? All 5 compared, every row linked to the page it was read from.

The only step this page cannot do.

Everything above is mechanical and takes about ten minutes. Whether it behaves the way you expect on your own accounts is the part nobody can write down for you.