Connect TradingView alerts to Nyria
Set up a TradingView webhook alert for a Nyria strategy: add the script, create the alert, check the format, send a test, and fix common mistakes.
Watch the setup
4:03TradingView sends an alert to Nyria as a webhook. Put the script on a chart, paste your strategy's alert message and webhook URL into a new alert, then select Check format in Nyria. The free TradingView plan can't send webhooks, so you need a paid plan with two-factor authentication on.
Prerequisites
- A Nyria strategy with TradingView as the alert source. If you have none, follow the quick start first.
- A connected broker. See the broker pages: Charles Schwab, Tradier, tastytrade, Alpaca.
- A paid TradingView plan with two-factor authentication on. The free plan can't send webhooks.
Step 1: Add the script to a chart
The same chart's Strategy Tester can go on your strategy's page too. See add a backtest.
Step 2: Create the alert
On your strategy in Nyria, open the Integration tab. Script type asks whether your script is a Strategy or an Indicator. Create the alert then lists every step of TradingView's alert dialog for each alert your strategy needs, with the alert name, message and webhook URL to copy. If your script sends its own message, select Use my own format on the Message step.
An indicator() script needs a separate alert for each condition on each
ticker. Convert it to a strategy first with
convert an indicator to a strategy,
so one Order-fills alert covers every side.
For each alert, in TradingView:
Alt + A (⌥ + A on Mac).alert() calls as extra messages. For an indicator, set Condition to your indicator and the alert condition for this side. Leave Interval on your chart's timeframe. If your script sends its own messages, choose alert() function calls only for a strategy, or Any alert() function call for an indicator.Tick each step in Nyria as you go. A card is marked set up on its own once Nyria receives an alert of its kind.
Keep the webhook URL private. Anyone with it can send alerts to your strategy. If it leaks, select Rotate token on the Integration tab and paste the new URL into your alert.
Each webhook takes 10 alerts at once, then 1 a second. An alert over that limit is dropped with a 429.
Step 3: Check format
Send a test alert
To test the webhook without waiting for TradingView, send this with your webhook URL. Bots on the strategy act on it, so test while only a paper bot is deployed.
curl -X POST '<your webhook URL>' \
-H "Content-Type: application/json" \
-d '{
"ticker": "SPY",
"action": "buy",
"marketPosition": "long",
"prevMarketPosition": "flat",
"price": 771.20
}'It returns 200 OK with "status": "processed", and the alert shows on the strategy's Logs tab.
About Once per bar close
On an indicator alert, use Once per bar close. Once per bar can fire twice in one bar and send conflicting orders, and Once only stops after the first alert.
Common pitfalls
1. Duplicate alerts
Symptoms: two webhook hits within a second of each other, and the broker shows two opens instead of one.
Causes, most common first:
- The TradingView alert is set to Once per bar instead of Once per bar close.
- Two alerts on the same chart for the same strategy, for example a cloned alert whose original was never deleted. Open the Alert manager on the right toolbar and delete the copy.
- Your Pine code calls
alert()in a block that runs on every tick. Wrap the call inif barstate.isconfirmed.
Nyria drops an identical alert body repeated within 30 seconds, or within 5 minutes with no other alert in between. To place a second order on the same bar (scaling in, for example), make each body different. A unique metadata.message_id is the simplest way:
{
"ticker": "SPY",
"action": "buy",
"metadata": { "message_id": "{{timenow}}" }
}2. Wrong webhook token
Symptoms: 404 Not Found in TradingView's alert log, or 400 Bad Request if the token was copied with a stray space.
Causes:
- The token was copied with a leading or trailing space. Use Nyria's copy button instead of selecting the URL by hand.
- The strategy's token was rotated. Open Integration, copy the new URL, and update every TradingView alert that points at this strategy.
- You pasted the strategy's public share URL (starting
https://app.nyria.io/share/...) instead of the webhook URL. Only thetrades.nyria.io/webhooks/...URL accepts POSTs.
3. Market order when you wanted limit, or vice versa
Symptoms: orders fill at a worse price than expected, or never fill and time out.
Causes:
- The payload sends
action(OPENorCLOSE) anddirectionwith anorder_typethat differs from the strategy's. On that shape the field in the alert overrides the strategy. Removeorder_typefrom the payload or change the strategy. - The payload is a position change (
marketPositionandprevMarketPosition) and setsorder_type. Nyria doesn't readorder_typeon that shape, so the strategy's order type applies. Set the order type on the strategy. See when Nyria readsorder_type. - Your strategy is set to Limit order but the payload has no
price. If the strategy's Limit target is Alert price, the alert is rejected. Otherwise Nyria uses the set target (bid, ask, mid or custom). Sendpricewhenever you mean a specific one. - You sent
"price": {{close}}on a low-liquidity symbol and the bar close is far from the current quote. Add a slippage buffer in your Pine code, or switch to market for low-liquidity tickers.
4. A placeholder arrives instead of the symbol
Symptoms: the strategy's Logs tab shows an entry refused for a symbol that reads {{syminfo.ticker}}, {{tickerid}} or similar, with the braces still in it.
TradingView substitutes only the placeholders it publishes and passes every other one through as literal text. A Pine variable name is not an alert placeholder: inside alert() you concatenate the value ('{"instrument":"' + syminfo.ticker + '"}'), while in the alert dialog's Message box you use {{ticker}}. Mix the two and Nyria gets the braces, not a symbol.
Fix it in the alert message. Adding the placeholder to the strategy's tickers does not help. See TradingView alert messages for every placeholder Nyria's check fills in.
5. Repainting strategies
Symptoms: the backtest wins 90% of its trades, and the same strategy loses money live.
The script shows entries that never fired live. Read TradingView repainting, then check your script fires on barstate.isconfirmed and reads higher-timeframe data as close[1].
Going from paper to live
Run the strategy on paper for at least 1–2 weeks. Compare every fill in the strategy's Logs tab with TradingView's alert log, to catch dropped or doubled alerts early.
In My bots, pause the bot on the paper account.
Deploy a new bot on the same strategy to your live broker account. The webhook URL stays the same.
The new bot is Active as soon as it deploys. The next TradingView alert goes to the live broker.
Next steps
- Convert an indicator to a strategy: turn an
indicator()script into astrategy()so one alert covers every side. - Webhook reference: every field Nyria accepts in the JSON payload.
- Alert sources: Discord, Telegram, TrendSpider and your own bot.
- Strategies: how Nyria turns a payload into an order using your strategy's settings.
- Troubleshooting: fixes by log message.
