WeCore
Guides

TradingView Alert JSON Message: Examples, Syntax and Mistakes

How to write a TradingView alert JSON message for webhook automation: valid syntax, placeholders, WeCore format examples, common mistakes and how to test safely.

WeCore·Published ·8 min read

A TradingView alert JSON message is the text you type into the alert's Message field so that a receiving system knows what to do when the alert fires. If the text is not valid JSON, or does not contain the fields the receiver expects, the alert fires on TradingView's side and nothing useful happens on the other side. This article walks through the syntax rules, the TradingView placeholders, the message format WeCore reads, several short worked examples and the mistakes we see most often.

It is about the message only. For the bigger picture of how alerts and webhooks fit together, read Automating TradingView Alerts with Webhooks. For a full alert-creation walkthrough, see TradingView alerts: a practical guide.

What TradingView does with your message

According to TradingView's help center page about webhooks (read 11 October 2026), the message is sent as the body of a POST request to your webhook URL. If the message is valid JSON, TradingView sends it with the content type `application/json`; otherwise it is sent as `text/plain`. That detail matters: a receiver that expects JSON will usually reject plain text, and TradingView will not warn you that your braces were wrong. You find out only by reading the alert log or the receiver's records.

TradingView also states that a request taking longer than three seconds is cancelled, that only ports 80 and 443 are supported, and that webhooks may occasionally fail to reach the URL. The message cannot change any of that, but it is a reason to keep messages short and complete: one alert, one self-contained instruction.

JSON in five rules

JSON is a plain-text format made of fields (keys) and values. For alert messages, five rules cover almost everything:

  1. The whole message is wrapped in curly braces: `{ ... }`.
  2. Keys and text values use straight double quotes: `"action":"buy"`. Single quotes and typographic "curly" quotes are not valid.
  3. Numbers are written without quotes: `"quantity":1`.
  4. Fields are separated by commas, with no comma after the last field.
  5. Nested objects use their own braces: `"stopLoss":{"type":"stop","amount":15}`.

A quick way to check a message before you save the alert is to paste it into any JSON validator, with the placeholders already replaced by sample values.

TradingView placeholders

Placeholders are names in double curly braces that TradingView replaces with real values when the alert fires. From TradingView's own help page on alert variables (read 11 October 2026), the common ones are:

PlaceholderWhat it returns
`{{ticker}}`The ticker of the symbol in the alert
`{{exchange}}`The exchange of the symbol
`{{close}}`, `{{open}}`, `{{high}}`, `{{low}}`Values of the bar on which the alert triggered
`{{volume}}`Volume of the triggering bar
`{{time}}`The bar's time, in UTC
`{{timenow}}`The moment the alert fired, in UTC
`{{interval}}`The chart's timeframe

Strategy alerts add order-related placeholders. TradingView's strategy alerts page lists `{{strategy.order.action}}`, `{{strategy.order.price}}`, `{{strategy.market_position}}`, `{{strategy.position_size}}` and `{{strategy.order.comment}}`; the strategy placeholder list also includes `{{strategy.order.contracts}}`. These are filled in only for real-time order events, never for orders on historical bars.

Quotes around placeholders

This is the single most common source of broken messages. A placeholder is replaced by plain text, so the quotes you put around it are the quotes that end up in the JSON. Text values need quotes, numbers do not:

  • Text: `"action":"{{strategy.order.action}}"` becomes `"action":"buy"`, which is valid.
  • Number: `"limitPrice":{{close}}` becomes `"limitPrice":24500.25`, which is valid. Writing `"limitPrice":"{{close}}"` sends the number as text, and many receivers will refuse it.

If a placeholder could return something that is not a plain number or word, check the alert log after the first firing to see exactly what was substituted.

The format WeCore reads

WeCore's webhook endpoint reads a JSON message with these fields. The names come from WeCore's own documentation inside the app:

  • `ticker` (or `symbol`): the instrument. You can send the continuous ticker such as `MNQ1!`, `MES1!`, `MGC1!`, `NQ1!`, `ES1!` or `GC1!`, and WeCore resolves it to the current front-month contract, so you do not edit the alert at each quarterly roll. Background on rolls is in futures contract rollover.
  • `action`: `buy`, `sell`, `exit`, `add`, `cancel`, `breakeven` or `protect`.
  • `quantity`: number of contracts, unless a dollar-based sizing method is set on the strategy subscription.
  • `orderType` and `limitPrice`: limit orders with an explicit price are the recommended setup.
  • `stopLoss`: an object with `type` and `amount`, where the amount is in points.
  • `takeProfit`: an object with `amount` in points.

Mini and micro contracts are different symbols with very different dollar value per point (`NQ` versus `MNQ`, for example, differ by a factor of ten). Sending the wrong one is a common reason a position looks ten times too large or too small. More on this in micro vs mini futures.

Worked examples

Each example is a single line, ready to paste into the Message field of an alert whose webhook URL points at your WeCore strategy. These are syntax illustrations only; the instrument, size and distances are placeholders for your own plan, not suggestions.

  • Entry with stop and target: `{"ticker":"MNQ1!","action":"buy","orderType":"limit","limitPrice":{{close}},"quantity":1,"stopLoss":{"type":"stop","amount":15},"takeProfit":{"amount":30}}`
  • Exit: `{"ticker":"MNQ1!","action":"exit"}`
  • Breakeven on an open position: `{"ticker":"MNQ1!","action":"breakeven"}`
  • Cancel working orders: `{"ticker":"MNQ1!","action":"cancel"}`
  • Attach protection to an open position: `{"ticker":"MNQ1!","action":"protect","stopLoss":{"type":"stop","amount":15},"takeProfit":{"amount":30}}`
  • Strategy alert with placeholders: `{"ticker":"MNQ1!","action":"{{strategy.order.action}}","quantity":1}`

The last line shows why strategy alerts are convenient: one alert can send both buys and sells because TradingView fills in the direction. Exit actions are handled separately in WeCore: exits are designed to pass through risk blocks so a position can always be closed. For how stops and targets are expressed in points, see automated stop-loss and take-profit for futures.

alert() scripts versus the message field

There are two ways a message reaches TradingView's alert engine, and mixing them up causes empty or broken alerts.

  • Message field: you type the JSON in the alert dialog. This is the normal route for simple indicator conditions and for strategy order alerts.
  • alert() function calls: the Pine Script itself builds the message text at runtime. TradingView's Pine documentation (read 11 October 2026) explains that when you create an alert on a script that calls `alert()`, you choose to trigger on alert function calls only, on order fills only, or on both. For the `alert()` route WeCore's guidance is to select "alert() function calls only" and leave the Message field empty, because the script supplies the text.

Pine's `alert()` also takes a frequency argument: `alert.freq_once_per_bar` (the default), `alert.freq_once_per_bar_close` or `alert.freq_all`. The choice decides whether one bar can send one message or many, which matters for duplicates (see below). If you build the message inside Pine, the same JSON rules apply, with the extra step of escaping quotes inside the string.

Common syntax mistakes

MistakeWhat happensFix
Curly "smart" quotes from a document or chat appMessage becomes text/plain and is rejectedRetype the quotes in the TradingView field
Trailing comma after the last fieldInvalid JSONRemove it
Missing closing braceInvalid JSONCount opening and closing braces
Text placeholder without quotes`"action":buy` is invalidWrap text placeholders in quotes
Number placeholder inside quotesPrice arrives as textRemove the quotes around numeric placeholders
Extra words around the JSONThe receiver cannot parse itThe Message must contain only the JSON
Empty Message field on a non-`alert()` alertNothing to readFill in the JSON
Wrong symbol sizePosition 10x offCheck mini versus micro in the ticker

Testing safely

Treat every new message as untested until you have seen it arrive. A sensible routine:

  1. Validate the JSON offline with sample values.
  2. Point the alert at a strategy whose broker account is in Simulation mode. New broker accounts in WeCore start in Simulation, and live trading becomes possible only after risk rules are saved. The article on simulation mode before going live covers this routine in detail.
  3. Trigger the alert and read TradingView's alert log, which shows delivery status, and then the signal shown in the WeCore app.
  4. Compare the order that arrived with what you intended: symbol, side, size, stop and target.
  5. Only then consider moving anything beyond Simulation, and only after reading your prop firm's current automation rules (see prop firms that allow automation).

If an alert does not seem to fire at all, work through TradingView alert not firing: troubleshooting before you edit the message.

Keeping messages maintainable

Small habits save time later. Keep one template per action and store it in a notes file. Change one field at a time. Name each alert after the strategy and the action it sends. When you edit a strategy's inputs, remember that a TradingView strategy alert runs on a copy of the strategy on TradingView's servers, so a chart-side edit does not change a running alert; delete and recreate it.

If you would rather not write rules yourself, you can browse WeAlgo ready-made strategies, which run on your own trading server with your own broker data. If you want to translate your own written rules into a strategy, the AI Strategy Builder inside the WeCore app (Tools, then Strategy Builder; it needs an active Start, Prop or Fleet plan) is available once you create an account. You can compare the plans first; there is a 7-day trial that starts with a $5 (refunded immediately) card verification.

FAQ

Does a TradingView alert message have to be JSON?

No. TradingView will send any text, but a receiver such as WeCore expects valid JSON with at least a ticker and an action. Plain text arrives as text/plain and is typically rejected.

Should I put quotes around `{{close}}`?

No, when the field is a number. `"limitPrice":{{close}}` produces a valid number. Quote only placeholders that return words, such as the order action.

Can one alert send both buy and sell?

With a strategy alert, yes: the `{{strategy.order.action}}` placeholder is filled in by TradingView with the order direction. With a simple condition alert, you normally create one alert per action.

Why does my message work in a validator but not in the alert?

Usually because of curly quotes introduced by copy and paste, or because a placeholder was left outside quotes. Open the alert log and compare the text that was actually sent.

Where do I test a new message?

In Simulation mode on a strategy connected to a simulated account, so a typo cannot place a real order. Read the signal in the app and check every field.

This article is general information, not investment advice. It makes no promise of results, and futures trading carries a high risk of loss. Check your broker's and prop firm's current rules before automating.

Sources and further reading