Guide

Connect TradingView Alerts to Binance (Webhook Guide)

Turn TradingView alerts into automatic Binance orders with a webhook: an OptAlgo bot, a Strategy Key, the alert message and the webhook URL. Paper first.

Updated

If you have a strategy or indicator alert in TradingView, you do not need a browser extension or a computer left running to turn it into an automatic order on Binance. When the alert fires, TradingView sends the signal to OptAlgo through a webhook, and OptAlgo opens the order on your connected exchange. This guide covers the setup from start to finish.

What you need

1. Connect Binance (for live trading)

OptAlgo connects to Binance through the Binance Link program. In the app you connect in one click through Binance's own consent screen; the key it creates is IP-restricted and cannot withdraw. Your assets stay in your account on the exchange, and OptAlgo only trades. If you want to try on paper first, leave this step for later: paper bots are simulated at real market prices and need no exchange connection.

2. Create a bot in My Bots

For a single-symbol bot you choose its name, the exchange, the market type (Spot or Futures), the symbol, the allocated amount and whether it runs on paper or live. Futures symbols end in .P, for example BTCUSDT.P. If you do not want to set the bot up in advance, create an automatic bot: its first signal sets the exchange, the symbol and the market type by itself.

Every bot has a Strategy Key. The alert message carries this key, and that is how OptAlgo knows which bot a signal belongs to. The key does not expire and stays valid until the bot is deleted; anyone who has the key can send signals to your bot. Do not paste it into public scripts, screenshots or chats.

3. Write the alert message

An example message for a long entry:

{
  "strategy_key": "PASTE_YOUR_STRATEGY_KEY",
  "exchange": "BINANCE",
  "ticker": "{{ticker}}",
  "position_side": "LONG",
  "action": "BUY",
  "leverage": 5
}

To close the position:

{
  "strategy_key": "PASTE_YOUR_STRATEGY_KEY",
  "exchange": "BINANCE",
  "ticker": "{{ticker}}",
  "position_side": "CLOSE"
}

Rules that keep the message from being rejected:

If you use a Pine strategy, the script itself can produce the message: it passes the JSON as alert_message to each strategy.entry and strategy.close call, and you write only {{strategy.order.alert_message}} in the message of a single alert. If you do not want to write any code, add the free OptAlgo Backtest template to your chart and paste your Strategy Key; the alert message is prepared for you.

4. Enter the webhook URL

Create the alert in TradingView and paste the JSON above into the message. In the Notifications tab, turn on Webhook URL and enter this address:

https://api.optalgo.com/signal-listener/signal

In the options, “Once Per Bar Close” is recommended, so the same signal does not arrive twice. Every delivery is processed.

5. Check it

After the alert fires, open the bot's logs in OptAlgo. The webhook returns 204 even when the signal is rejected; the logs are where you see the outcome. A new bot shows as unverified until its first valid signal; that signal verifies the bot and you get a notification. Every filled order and every error also lands in your Telegram.

Paper first, then live

Start the bot on paper and watch a few alerts get handled the way you expect. Paper trades have no stop-loss or take-profit order on the exchange side; they open and close with your signals. When the numbers hold up, you switch the bot to live from My Bots; a bot with an open trade cannot switch between paper and live.

Common problems

If you want to trade many coins with one key, multi-symbol bots support up to 10 open coins on Plus and 20 on Pro. All the alert message examples (partial close, moving the stop, multi-symbol bot) are in the docs. For an overview of the product, see the TradingView bots page.

Your next strategy is one sentence away.
Test it honestly before it touches money.

Start free, no card

50 backtest units a month on the Free plan.