Pine Script webhook alerts
Three open-source Pine Script v6 indicators. Each one sends a webhook body TradeAlert can read aloud when the bar closes. Copy a script into TradingView, point the alert at your webhook URL, and the phone call speaks the sentence in the body.
The scripts are published here under the Mozilla Public License 2.0. TradingView House Rules do not allow a product link inside a script, so the source names the JSON fields and nothing else.
Webhook Alert Message
Sends the webhook body when price closes across a level you set. Use it to check the message, or as the pattern for your own condition.
webhook-alert-message.pine
Phone Me on Breakout
Calls when a bar closes beyond the high or low of the previous N bars. The current bar is not part of that range.
phone-me-on-breakout.pine
Opening Range Breakout
Records a clock window, such as 09:30 to 10:00 New York, then calls when a later bar that day closes outside the window.
opening-range-breakout.pine
What the phone says
A buy or sell body includes strategy.order_action, ticker, and action. TradeAlert announces the side only when both the order action and the ticker are present. The action sentence is spoken after that. A body with only text is spoken as a TradingView alert, with no side.
{"strategy":{"order_action":"buy"},"ticker":"AAPL","action":"Closed above the 20-bar high at 190.25."}That call says: "You have a buy signal for AAPL. Closed above the 20-bar high at 190.25."
{"text":"Test alert. Price is 190.25."}That call says: "TradingView alert: Test alert. Price is 190.25."
Add a script to a chart
- Copy your webhook URL from the dashboard. The format is
https://www.tradealert.pro/hook/{username}/{api-key}. Setup is in the TradingView setup guide. - Open one of the source files above and copy the whole script.
- In TradingView, open the Pine Editor, paste, save, and add the indicator to the chart.
- Webhooks need TradingView Essential or higher, with 2FA. On a daily chart, use the message template or the breakout script. Opening Range Breakout needs an intraday chart.
Create the alert
- Click the alert clock, then Create alert.
- Set Condition to the indicator name, then Any alert() function call. The message box in the dialog is ignored. The script sends its own JSON.
- Open the Notifications tab, enable Webhook URL, and paste your TradeAlert URL.
- For Webhook Alert Message, set a price level and turn on Arm price-level alert before you create the alert. Arm is off by default. Recreate the alert after you change an input. A running alert keeps the inputs from when you created it.
One alert per event
Each script alerts on the bar close, and only on the bar that crosses. Later bars that stay outside the level do not call again. Phone Me on Breakout can require extra volume. Leave that filter off for symbols that do not report volume.
Check it
On Webhook Alert Message, turn on "Send one test on the next bar close". When that realtime bar closes, the phone reads the test sentence once. Then turn the test off and recreate the alert so it does not stay armed.
The same JSON shape is what the Pine Script alert tutorial builds by hand. These three scripts are that shape, already tied to a price event.