Free strategy check — send your trading rules and we tell you within 24 hours if they can be automated. No obligation. Send your rules →
Pine Script12 Sep 2026 · Eye Algo

TradingView can send an alert to a webhook URL when your Pine Script condition fires. Another program can receive that message and place the trade. This article explains the steps, the common pitfalls and what a complete setup needs.

How it works

  1. The Pine Script calls alert() or uses alert conditions with a clear message, for example a JSON text with symbol, side and size.
  2. You create the alert in TradingView with your webhook URL.
  3. A receiving service reads the message and sends the order to your broker.

TradingView only sends the message. It does not place trades on its own, so the receiving service is the part that connects to your broker, through an API or through a MetaTrader EA that polls for new commands.

Writing a good alert message

The receiver has to understand the message without guessing. Keep it structured and include only what is needed.

  • The symbol and the action, such as buy, sell or close.
  • The size or risk amount, if the receiver should not decide it.
  • A strategy or account identifier, so one receiver can serve several scripts.
  • A secret token that the receiver checks, so strangers cannot send orders to your URL.

Watch out for

  • Alerts that fire on the open bar and then change (use bar-close alerts for most strategies).
  • Delays between the alert and the order.
  • Webhook alerts need a paid TradingView plan.

Why alerts can disagree with the chart

A condition that is true in the middle of a bar may be false when the bar closes. If the alert fires on every tick, you may get an order for a signal that later disappears. Bar-close alerts avoid this, at the cost of acting a little later. This is closely related to repainting, which we cover in how to spot repainting indicators.

Reliability of the receiving side

The receiver should run all the time, so it usually sits on a VPS. It should log every message it gets, reject duplicates, check that the symbol and size make sense, and confirm the order with the broker. If the broker rejects the order, you should get a Telegram or email alert. A webhook flow has several steps, and a failure at any one of them means a missed or wrong trade.

Note: Alerts can be delayed, and fills can differ from the chart price because of spread and slippage. Automation executes your rules, it does not make a strategy profitable. Test with small size first.

When to use alerts and when to use an EA

Webhooks suit strategies that already live in Pine Script and are tested on TradingView. If you would rather have everything inside MetaTrader, we can convert the Pine logic to an EA, see Pine to EA conversion. For Pine work itself, see Pine Script development. Typical pricing starts at Rs 3,000 for simple work and Rs 7,000 for advanced work, as listed on the pricing page. You get a working demo before final payment.

An example message layout

A webhook message is plain text. Many setups use JSON, which a receiving service can read easily. A message might hold the symbol, the side, the size or risk percentage, a strategy name and a secret token. Keep names short and consistent, and avoid special characters that can break the format. In Pine Script you can build the message from variables, so the same script can send different sizes or symbols without edits.

Think about the full set of events, not only entries. The script should also send exit and stop messages, otherwise the receiver does not know when to close a trade. Decide who owns the stop loss: the broker order placed by the receiver, or a new alert from TradingView. A stop that lives only in an alert depends on the whole chain working at that moment, so a stop placed at the broker is usually safer.

Testing the whole chain

Test every link before using real money. First check that the alert fires at the bar close you expect. Then check that the receiver gets the message and logs it. Then send a small order on a demo account and confirm the size, symbol and direction are right. Finally, test failures: send a message with a wrong token, send the same message twice, and stop the receiver for a few minutes and see what happens when it returns.

  • Is the alert set to once per bar close, and not on every tick?
  • Does the receiver reject duplicates and unknown tokens?
  • Does the broker confirm every order, and do you get an alert when it does not?
  • Is there a manual way to stop everything quickly?

Alerts also have limits set by TradingView, such as the number of active alerts allowed by your plan, so check what your plan includes.

Frequently asked questions

Do I need a paid TradingView plan for webhooks?

Yes, webhook alerts need a paid plan. Check TradingView's current plan details before you start.

Can TradingView place trades directly on my broker?

Only through broker integrations that TradingView supports. For other brokers you need a receiving service or an EA that reads the alert and places the order.

How do I stop others from sending orders to my webhook?

Include a secret token in the message and make the receiver check it. Keep the URL private as well.

Have a strategy you want automated?Get a free strategy check
← All articles