All guides

TradingView webhook to Binance: turning a Pine Script alert into an order

Updated 3 min read

TradingView can tell you when your Pine Script condition is met. It cannot place an order on Binance for you. To get from an alert to an order you need something in the middle that receives the alert, checks it, and sends the order to Binance with your API key. This guide explains that chain. It uses Stralines as the example and is educational only.

The chain, end to end

  1. Your Pine Script decides that a condition is met and fires an alert.
  2. TradingView sends the alert as a webhook: a short message posted to a web address you supply.
  3. A receiver at that address checks the message is really yours, works out the order, and applies your size and risk settings.
  4. Binance receives the order through the API, on your own account.

Steps 1 and 2 are TradingView. Step 4 is Binance. Step 3 is the part you either build and host yourself or get from a platform.

What the receiver has to get right

Writing a script that forwards an alert to Binance is a weekend project. Running one with money on it is harder, because of what happens on the bad days:

  • Is the alert really yours? The address is reachable by anyone, so each message must carry a secret that the receiver checks.
  • Duplicates. TradingView can fire the same alert twice. The receiver must not open two positions.
  • Rounding and minimums. Binance rejects orders with the wrong price step or a size below the minimum.
  • The stop-loss. Placing a stop is not the same as having one. If Binance rejects or later cancels it, something has to notice and put it back.
  • A record. When a trade looks wrong, you need to see what was received and what was sent.

Doing it on Stralines

On Stralines this is called a custom bot.

  1. Create a custom futures bot. You can paste your own Pine Script, or build the rules from a set of indicators and let the platform generate the Pine Script.
  2. Set the stop-loss and take-profit rules for the bot.
  3. The bot gets its own webhook address and passphrase. Keep the passphrase private: anyone who has it can send signals to your bot.
  4. In TradingView, add the script to a chart for your pair and create an alert that posts to that address.
  5. Connect your Binance key with read and trade permission only. Stralines refuses Binance keys that allow withdrawal.

Start on the Binance practice account (testnet). Custom bots on practice accounts trade for free.

No paid TradingView plan?

TradingView offers webhooks on its paid plans. If you do not have one, choose the option to let the platform set up the alert for you when you create the bot. The Stralines team sets it up and you are told when it is live.

What to keep in mind

The receiver does not make the strategy sound. A backtest on TradingView is a study of the past, and live fills, fees and funding will differ from it. See Backtest without a control and Why your stop-loss disappears.

How many custom bots you can run depends on your plan; the table is on the pricing page.


Educational content only. Stralines is software for executing and managing your own trading rules, and is not affiliated with TradingView or Binance. Nothing here is investment advice, and trading carries risk of loss.

Welcome to Stralines

New accounts can claim ₹3,800 worth of credits.

Continue with Google

Or