Webhook Configuration

Learn how to create and configure webhooks for TradingView

Webhook Configuration

Complete guide to create webhooks and connect them with your TradingView alerts.

What is a Webhook?

A webhook is equivalent to an alert configured in TradingView. Each webhook you create will receive signals from a single TradingView alert. It's important to understand that one webhook = one alert.

⚠️ Important: You cannot configure two different alerts in TradingView pointing to the same webhook. Each alert must have its own unique webhook, otherwise it may cause unexpected behavior.
💡 Practical tip: To keep everything organized, give the webhook the same name as your alert in TradingView. Also, use the webhook's description field to add useful information that allows you to quickly identify which strategy or configuration it is.

Once the webhook is created, you can connect it to multiple MT5 accounts through the Connection Editor, allowing you to distribute signals from that alert to different brokers or accounts.

Create a Webhook

1
Go to the Webhooks section
In the sidebar, click on Webhooks. You will see a list of all your existing webhooks.
2
Create a new webhook
Click on the "Create Webhook" button. A unique URL and authentication token will be automatically generated. Recommendation: Give the webhook the same name that your alert will have in TradingView to keep everything organized.
3
Copy the webhook URL

On the webhook page you will find a button to copy the URL. This is the destination where TradingView should send the signal. You must copy it and paste it in the "Webhook URL" field of the "Notifications" section of the alert you are creating in TradingView.

4
Copy the JSON

On the webhook page you will find a button to copy the JSON. This is the message that TradingView should send. You must copy it and paste it replacing all content in the "Message" field of the "Message" section of the alert you are creating in TradingView.

Do not change this JSON. If you want optional take profit or stop loss, your strategy must put them in the order comment (see below)—not here.

Configure in TradingView

1
Add your strategy to the chart
First, add your Pine Script strategy to the TradingView chart. Important: You must use a strategy, not an indicator. Strategies are what generate buy and sell signals that can be sent via webhooks.
2
Create a strategy alert
Once your strategy is on the chart, right-click and select "Create alert" or use the alerts button. The alert will be automatically created based on your strategy.
3
Add the Webhook URL
In the "Notifications" section, check "Webhook URL" and paste the URL you copied from the webhook in TPL Cloud.
Webhook URL configuration in TradingView
4
Configure the message
In the "Message" field, paste the JSON from TPL Cloud exactly as in the image. Never edit this JSON. Take profit and stop loss are not written here: your strategy must include them in each order’s comment when it opens a trade (next section). TradingView forwards that comment for you—you do not need to touch the JSON for TP/SL.
JSON message configuration in TradingView
5
Save and activate
Save the alert and activate it. Every time your strategy generates a buy or sell signal, TradingView will automatically send the signal to TPL Cloud and it will execute on your MT5.
⚠️ Important reminder: This TradingView alert must be the only one pointing to this webhook. If you need to use a different alert, create a new webhook for it. Configuring multiple alerts on the same webhook will cause unexpected behavior.

Optional take profit and stop loss (from your strategy)

Start here—it's simple: in most cases you do not need to change your strategy code or the webhook JSON for take profit and stop loss to work. Your strategy already defines when to open and when to close. When price hits the TP or SL from the strategy logic, TradingView sends a close alert; we receive it and your account executes the close. That is why you usually won't see TP/SL lines on the MetaTrader position: the exit happens when that alert arrives, not because those levels were stored on the broker ticket. That is normal and expected—not a mistake.

So the extra feature on this page is optional. Use it only if you want TP and SL to appear on the MT5 order (e.g. prop firm rules, checks, or personal taste). Same idea of execution—just visible levels on the ticket.

Quick answers
  • TP/SL in the JSON? No—leave the alert message as we provide it.
  • If a close alert arrives but the position is already closed, we do nothing—no problem.

If you do want broker-style TP/SL on the MetaTrader order, you can send levels with each signal without editing the webhook JSON. Your strategy must add a fixed text block in the order comment when it opens (or adjusts) a trade. TradingView forwards that comment automatically. Details below.

In short
  • Default path: no code changes—TP/SL close via TradingView alerts.
  • Keep the alert Message (JSON) exactly as we give you.
  • Only if you want TP/SL on the MT5 ticket: add the block below in your strategy's order comment.

Put this block inside the order comment (you may add your own words before or after; keep the braces and spelling exact):

{TradingPineLab:tp=X,sl=X,applyOptionsToAllOrders=false}
  • tp (optional) — TP price to set on the order.
  • sl (optional) — SL price to set on the order.
  • applyOptionsToAllOrders (optional, default false) — If false, TP/SL apply only to the order executed by that signal. If true, all open positions for the same strategy (same webhook / symbol) are updated to the same TP/SL.

For a single entry you can send for example:

{TradingPineLab:tp=123.45,sl=122.10}

If you edit your strategy in TradingView (Pine Script), a typical pattern is: compute prices, then pass them in comment=. Use commas between tp, sl and applyOptionsToAllOrders:

tempTP = close + (close * 0.01)
tempSL = close - (close * 0.01)
strategy.entry('Bull #1', strategy.long, qty = baseOrderSize, comment = 'Compra TEST {TradingPineLab:tp=' + str.tostring(tempTP) + ',sl=' + str.tostring(tempSL) + ',applyOptionsToAllOrders=true}')

Replace baseOrderSize with your size variable or fixed quantity.

Valid examples:

{TradingPineLab:tp=1.2345,sl=1.2300,applyOptionsToAllOrders=true}
{TradingPineLab:tp=1.2345,applyOptionsToAllOrders=false}
{TradingPineLab:sl=1.2300,applyOptionsToAllOrders=true}
{TradingPineLab:tp=123.45,sl=122.10}
Good to know No block in the comment = same behaviour as before. The broker may reject TP/SL that are too close to the market (minimum distance rules).

Connect Webhook with Accounts

Once the webhook is created, you need to connect it with your MT5 accounts. This is done in the Connection Editor:

  1. Go to the Connection Editor
  2. Drag the webhook from the left list to the canvas
  3. Drag an MT5 account to the canvas
  4. Connect them to create a Mapping between both
  5. Configure the symbol in the mapping. This symbol will be the one used by the connected account
  6. Save the connection
💡 Tip: You can connect the same webhook to multiple accounts. Each connection can use a different symbol, allowing you to trade the same asset on different brokers or use different instruments on each account.

Troubleshooting

The alert does not execute
  • Verify that the webhook URL is correct
  • Check that the alert is active in TradingView
  • Verify that the webhook is connected to an account in the Connection Editor
JSON format error
  • Make sure to use the exact example JSON we provide
  • Do not modify the Pine Script variables ({{strategy.order.action}}, etc.)
  • Verify that all quotes are properly closed