TradingView Webhook JSON: Complete Alert Syntax Guide

TradingView Webhook JSON is the structured message an alert sends to an external service. To use it with PickMyTrade, you need valid JSON, values supplied by the correct alert type, and fields that match your integration. Passing a JSON syntax check alone doesn’t prove the message will place the intended trade.

This reference covers JSON alert syntax, strings and numbers, TradingView placeholders, script-generated messages, and validation for PickMyTrade’s Tradovate integration. Start with your current generated configuration. The short examples below teach specific rules; they aren’t complete, ready-to-trade account configurations.

Key takeaways

  • Valid JSON and valid trading instructions are separate requirements.
  • Double quotes create strings; unquoted numeric values create numbers.
  • Choose the correct message route: indicator condition, strategy order fill, or scripted alert().
  • Keep generated routing and risk settings intact.
  • Validate the actual outgoing message and test entry and exit in demo.

What is TradingView Webhook JSON?

A TradingView webhook sends the alert message to a configured endpoint using an HTTP POST request. JSON provides a structured way to represent that message. TradingView determines the content type from the message format; the receiving service defines which keys, values, and trading instructions it accepts.

TradingView’s webhook documentation says valid JSON is sent as application/json, while other text uses text/plain. Webhook use also requires two-factor authentication. Enable the Webhook URL notification and use the destination supplied by your integration rather than a copied endpoint from another account.

Think of validation in three layers: the text must parse, the fields must match the receiver’s contract, and the resulting order must satisfy account and broker rules. For example, a syntactically valid quantity of one can still target the wrong account. A successful delivery response doesn’t establish a broker fill.

TradingView Webhook JSON syntax rules

Use double-quoted property names, a colon between each key and value, and commas between members. Keep JSON types distinct. The JSON standard, RFC 8259, defines objects, arrays, strings, numbers, booleans, and null. A parser can catch broken structure, but it cannot identify your intended trading behavior.

ElementValid exampleCommon mistake
String"symbol": "MNQ"Single or curly quotation marks
Number"quantity": 1Comma-separated number such as 1,000
Boolean"enabled": falseFalse or "false" when a boolean is required
Array"items": [1, 2]Missing closing bracket
Null"value": nullNone or NaN

JSON doesn’t support comments or trailing commas. Avoid duplicate keys because parsers can handle them inconsistently. A backslash or quotation mark inside a string needs escaping. Whitespace and line breaks between members are fine, so a neatly formatted payload can be easier to review than a compressed one.

{
  "example": "syntax only",
  "quantity": 1,
  "enabled": false,
  "note": "A \"quoted\" word"
}

This generic example illustrates syntax only. The keys example, enabled, and note are not presented as PickMyTrade order fields. Don’t send a generic JSON teaching example to an execution webhook and expect the service to infer an account, symbol, or action.

Where should you paste the alert JSON?

For the generated-message workflow, paste the JSON into the alert’s Message field. Put the generated destination into Webhook URL under Notifications. Use the alert name only as a short label. The PickMyTrade alert setup guide shows this process.

  1. Open Generate Alert in PickMyTrade and select the intended setup and account.
  2. Review symbol, action, sizing, and protection settings before copying the configuration.
  3. Create or edit the appropriate TradingView alert.
  4. Paste the generated JSON into Message, without Markdown fences or explanatory text.
  5. Enable Webhook URL and paste the current generated destination.
  6. Check the selected condition, event type, expiration, and alert status.

A custom Pine alert() script uses a different message source, explained below. Don’t overwrite fields blindly when troubleshooting. First identify whether TradingView is sending the dialog message, a custom order-fill message, or the string constructed by the script.

Which alert type supplies the message?

The event source determines where the outgoing text comes from. TradingView’s alerts FAQ distinguishes indicator alert conditions, scripted alert() calls, and strategy order fills. Select the route your script and receiver expect; otherwise you can send well-formed JSON on the wrong event or send unintended extra messages.

RouteMessage sourceConfiguration to inspect
Indicator alert conditionMessage template with supported placeholdersThe indicator’s selected buy, sell, or exit condition
Strategy order fillAlert dialog template or custom order messageOrder-fill events and appropriate strategy placeholders
Scripted alert()The runtime string built by PineScripted alert events and the actual generated string

PickMyTrade’s standard strategy setup specifies Order fills only where event choices are offered. A deliberately designed custom alert() integration can use its own compatible message route. Enabling combined events without reviewing the script can send both an execution message and unrelated script text.

How do TradingView placeholders work in JSON?

Placeholders insert alert-time values into supported message templates. They don’t define the receiver’s schema or guarantee valid field types. Use general chart placeholders in the appropriate context, strategy placeholders for strategy events, and plot references for the intended script outputs. Validate the rendered message after substitution.

PlaceholderValue representedCheck before use
{{ticker}}Chart tickerBroker mapping may require a different instrument representation
{{close}}Bar close value at the eventIt is not automatically the external broker’s fill price
{{timenow}}Alert firing timeMatch the timestamp format required by the receiver
{{strategy.order.action}}Strategy order directionA sell can reduce a long; it doesn’t necessarily mean open a short
{{strategy.order.contracts}}Strategy order quantitySeparate it from position size and external account multipliers
{{strategy.order.alert_message}}Custom order messageDetermine whether it contains a complete JSON object or a smaller value

Use TradingView’s placeholder reference for exact names and supported contexts. Don’t put strategy-specific placeholders into indicator alerts. For plots, identify the exact plot name or index and verify that it supplies a usable value when the event fires.

Quoted and unquoted prices produce different types

{"price": "{{close}}"}

Illustrative rendered output with a close value of 123.45. The price value below is a JSON string.

{"price": "123.45"}

After substitution, a value such as "123.45" remains a JSON string. TradingView doesn’t remove the surrounding quotes. A receiver may explicitly accept numeric strings, but that is a receiver-specific conversion. Preserve the type used by the current generated configuration instead of assuming strings and numbers are interchangeable.

{"price": {{close}}}

Illustrative rendered output with a close value of 123.45. The price value below is a JSON number.

{"price": 123.45}

This second example is a template, not valid JSON before substitution. If the rendered value is 123.45, the result contains a JSON number. Validate the rendered output for unavailable values as well. Bare na or an empty value cannot serve as a valid JSON number.

Named and indexed plot placeholders

TradingView supports indexed references such as {{plot_0}} and named references such as {{plot("Upper Band")}}. Match the exact plot title and the indicator selected for the alert. The official placeholder guide documents both forms. The example below is a template, not a complete order payload.

{"upper_band": {{plot("Upper Band")}}}

If that plot returns 125.5 at the alert event, the rendered example is:

{"upper_band": 125.5}

Here, upper_band is a teaching field, not a PickMyTrade execution key. For actual SL or TP fields, use the supported generated structure. Check the Data Window to identify which output is the upper band and which is the lower band, then confirm the values in a controlled alert.

An unavailable plot value needs an explicit handling rule. Don’t silently delete a protective-order field to make the message parse. In a custom script, gate an entry until required values are available; preserve an intentional exit and protection plan for existing positions. If you cannot edit the script, ask its developer to handle missing data.

PickMyTrade JSON fields: what should you review?

Use PickMyTrade’s generated payload as the execution reference. Its JSON configuration documentation covers strategy and indicator examples. The tables below cover field groups, representations, and conditional checks. They do not define undocumented defaults or guarantee every combination. The complete reference here concerns alert syntax and message construction; current execution settings come from the generator.

Configuration groupExample field namesReview question
Instrument and eventsymbol, date, dataDoes the message identify the intended instrument and action?
Sizingquantity, risk_percentageWhich sizing method is active?
Price and protectionprice, tp, sl, percentage and dollar variantsAre the units and protection method correct?
Authentication and routingtoken, account_id, multiple_accountsDoes the generated structure target the intended account?
Order behaviororder_type, pyramid, reverse_order_closeDoes the route support the requested behavior?
Field or groupRepresentation to preserveConditional check
symbol, dataStringsMatch instrument mapping and supported action
dateTimestamp string in the generated templateDo not substitute an arbitrary date format
quantityFixed numeric size or the documented placeholder representationStrategy order quantity can be a quoted placeholder in the official example
risk_percentageNumeric percentageRisk-based sizing needs valid stop and balance inputs
priceGenerated numeric or numeric-string representationVerify order-type interaction; do not infer market versus limit from this field alone
tp, sl and their variantsNumbers with the configured price, percentage, or currency unitsConfirm the selected method and its units in Generate Alert
token, account_idCredential and identifier stringsUse the exact current destination; do not rely on an assumed default account
multiple_accountsArray of account objectsPreserve each destination and applicable multiplier
Boolean behavior switchesUnquoted true or falseConfirm compatibility with the chosen alert route
Representation checklist based on documented examples, not a guarantee of every field combination. Use the current generator as the execution reference.

Keep nested objects and arrays exactly where the generated configuration requires them. Don’t rename fields to match another vendor’s example. Also avoid simplifying a payload by deleting routing or protection fields merely because the remaining text still parses. Syntax validity doesn’t establish that the edited object preserves the original trade instructions.

For advanced behavior, follow the dedicated pyramiding and reverse-order documentation. Check compatibility with your indicator or strategy route before changing these settings. Existing positions, explicit strategy exits, and opposing signals can interact differently; a boolean switch should never be treated as a cosmetic syntax choice.

Can Pine Script build TradingView Webhook JSON?

Yes. Pine can construct a JSON-formatted string using calculated values. For alert() messages, build the actual values into that string because this route doesn’t process alert placeholders. The small example below demonstrates message construction only. It is not a PickMyTrade execution schema or a complete trading strategy.

//@version=6
indicator("JSON construction example", overlay = true)
float average = ta.sma(close, 20)
bool signal = ta.crossover(close, average)
if signal and barstate.isconfirmed and not na(close)
    string message = '{"example":"syntax only","price":' + str.tostring(close, format.mintick) + '}'
    alert(message, alert.freq_once_per_bar_close)

Validation status: the example’s constructed JSON has been checked locally with representative numeric values. The Pine code has not been compiled in TradingView or used to place orders. Before deployment, compile it in Pine Editor, create the intended scripted alert, and inspect the emitted message in a controlled test.

Pine’s outer single quotes delimit the Pine string; the JSON property names inside it still use double quotes. If you include arbitrary text, escape characters that would break the resulting JSON. Test the final output. A script that compiles can still construct invalid JSON for a particular runtime value.

For custom strategy order-fill messages, Pine’s alert_message parameter is a separate route. When it contains the entire payload, use {{strategy.order.alert_message}} as the complete dialog message rather than quoting it as an action value. Review every order call expected to emit an execution message, including exits.

How do you diagnose JSON alert errors?

Read both the outgoing message and the receiver’s full response. A JSON parser identifies syntax problems. A receiver validation error identifies an unsupported or invalid field value. Broker order records identify execution problems. PickMyTrade’s alert error reference helps separate these stages.

SymptomCheck
415 Unsupported Media TypeInspect content type and actual body; malformed JSON is one possible cause, not a universal diagnosis
Literal {{close}} receivedCheck the message route and placeholder processing
Invalid numeric valueCheck quotes, units, missing data, nulls, and rendered values
Symbol Mapping Not FoundReview symbol mapping; valid JSON alone cannot fix it
Account or token rejectionCompare current generated routing and authentication settings
Order rejected at brokerInspect account permissions and the requested order

Don’t delete a price, stop, or account field just to suppress a parsing error. Find the source of the invalid value. A changed field can alter position sizing or exit behavior even if the next request is accepted. Keep the original configuration available for comparison while testing the correction.

Validation checklist before enabling execution

Validate the template and actual message as separate artifacts. First check fixed JSON structure where possible. Then inspect a rendered alert with representative values and verify receiver-specific fields. Use redacted copies or a trusted local validator so tokens and account credentials aren’t uploaded to a public formatting website.

  1. Confirm the alert source and selected event type.
  2. Remove Markdown fences, comments, and surrounding prose.
  3. Check commas, braces, brackets, and string escaping.
  4. Verify placeholder names and their supported context.
  5. Inspect rendered values and their JSON types.
  6. Compare keys, nesting, units, account, and action with the generated configuration.
  7. Test a controlled demo entry and exit and verify broker records.

Retain the event timestamp, redacted actual body, delivery status, PickMyTrade result, and relevant order ID for troubleshooting. Check existing positions and working orders before retrying. If you changed strategy code or inputs, recreate the running alert so the new version is captured, as TradingView documents.

Frequently asked questions

Is there one universal TradingView Webhook JSON format?

No. TradingView sends the alert body; the receiving service defines its schema. A generic JSON example may parse but lack the fields required by PickMyTrade. Generate the configuration for your connection, then validate the actual values sent by the selected alert route.

Should numeric placeholders be inside quotes?

Follow the receiving service’s expected types. A quoted placeholder becomes a JSON string after substitution; an unquoted numeric expansion can become a number. Some templates only parse after rendering. Check the actual result and preserve the type used by your current generated configuration.

Why does {{close}} arrive as literal text?

Check whether the message comes from a scripted alert() call. That route doesn’t process alert placeholders. Build the value into the Pine string instead. For template-based messages, check the placeholder spelling and whether the selected alert type supports it.

Does valid JSON guarantee that PickMyTrade places an order?

No. The request must also satisfy authentication, routing, field validation, and account rules. Even an accepted instruction may produce a rejected or unfilled broker order. Match the alert with the broker record and verify the instrument, quantity, status, and resulting position.

How do I send a complete JSON payload through alert_message?

The Pine order call’s alert_message argument can supply a full JSON-formatted string. In that design, use {{strategy.order.alert_message}} as the entire alert dialog message. Don’t wrap the object in another quoted field. Confirm that all relevant entry and exit events provide compatible messages.

Use the generated configuration as your execution reference

A reliable TradingView Webhook JSON setup needs correct structure, correct dynamic values, and correct trading instructions. Keep those checks separate. Use the PickMyTrade JSON configuration guide for the execution fields, then verify a controlled demo entry and exit before relying on the route live.


Disclaimer:
This content is for informational purposes only and does not constitute financial, investment, or trading advice. Trading and investing in financial markets involve risk, and it is possible to lose some or all of your capital. Always perform your own research and consult with a licensed financial advisor before making any trading decisions. The mention of any proprietary trading firms, brokers, does not constitute an endorsement or partnership. Ensure you understand all terms, conditions, and compliance requirements of the firms and platforms you use.


Also Checkout: Maximum Order Quantity Has Been Met: How to Fix It

Automate Your TradingView Strategies
Connect your alerts with PickMyTrade — automated trade execution, no coding required. Start free →
For AI tools & developers:View Markdown →

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Markdown version