Short answer: TradingView to Interactive Brokers means two different things: the broker link, where you place orders by hand from TradingView's chart, and webhook automation, where software you run receives an alert and sends an order through TWS, IB Gateway or the Web API. TradingView says automated strategy trading with a brokerage account is not available yet, IBKR says Pine Script is not supported for trading, and TradingView's terms, read on 5 November 2026, prohibit using alerts and webhooks for automated trading. Check those terms first; automated orders can lose money.
TradingView's Terms of Use (opens in a new tab), read on 5 November 2026, describe alerts and webhooks as licensed for display use and prohibit using them for automated trading, including through third-party products or services. Read those terms and take legal advice before relying on the webhook route; it is your agreement with TradingView. This guide separates the two routes, from both companies' pages read that day. No IBKR account or TradingView webhook was available, so the receiver below ran only against synthetic alerts and a mock socket, never a real session.
No broker or product is recommended or ranked, and there are no referral links. Rules depend on your country and account type: IBKR says its restriction on Canadian products (opens in a new tab) extends to platforms such as TradingView. For readers in Turkey, separate rules apply to leveraged FX with foreign firms: the Capital Markets Board said on 23 February 2023 (opens in a new tab) that residents may trade leveraged products only through firms it has authorized (Law No. 6362 (opens in a new tab) Articles 99(4) and 109(2)). Crypto is among the security types IBKR lists for this integration, and Article 99/A of Capital Markets Law No. 6362 treats activity by foreign crypto-asset platforms directed at Turkish residents as unauthorized.
What does connecting TradingView to IBKR actually do?
The broker link lets you click orders from the chart; anything that places orders without a click is a separate system that you or a vendor must run.
| Route | Who places the order | What must run | Login |
|---|---|---|---|
| Broker link in the Trading Panel | You, by hand | A browser | IBKR login; other logins on that username can end the session |
| Webhook to your receiver, then TWS API | Your software | Receiver plus TWS or IB Gateway | Manual login in a window; about weekly with auto-restart |
| Webhook to your receiver, then Web API | Your software | Receiver plus Client Portal Gateway on one machine | Manual browser login, daily |
| Webhook to a hosted third-party bridge | A vendor's software | Nothing of yours, but your account is connected to theirs | Vendor's route; IBKR requires Compliance approval of third-party Web API vendors |
IBKR's integrations list (opens in a new tab) gives TradingView's link as CPAPI with OAuth and says the list is not an endorsement. Which of those two API routes suits a receiver is covered in IBKR Web API vs TWS API.
How to connect IBKR to TradingView
Open the Trading Panel in TradingView, choose the Interactive Brokers tile, click Connect and sign in with your IBKR credentials; live and paper use separate logins.
| Item | What IBKR says |
|---|---|
| Accounts | An open TradingView account and an open IBKR account funded with at least USD 1; demo accounts are not officially supported |
| IBKR market data | USD 500 plus subscription cost, if you want IBKR's data |
| Tradable | Stocks, US equity and index options, futures, crypto, forex |
| Not tradable | Bonds, CFDs, futures options, EMEA and APAC options, warrants |
| Forex | Needs Virtual Forex permission |
| Extra users | Need Trading Access and TWS user access rights |
IBKR's pages conflict: its TradingView landing page (opens in a new tab) mentions bonds and its non-tradable symbols page (opens in a new tab) names options and crypto as unsupported, while the supported security types page (opens in a new tab) excludes bonds and lists options and crypto. Its general FAQ (opens in a new tab) requires a funded IBKR Pro account for third-party platforms; the TradingView requirements do not mention Pro, so check this if you hold IBKR Lite. Common errors:
- No trading permission. IBKR requires a permission per security type, held on the username: check the product's permission, Virtual Forex for forex and an extra user's access rights. IBKR's documents do not list this exact message, so this is the documented cause, not a confirmed match.
- Failed to generate sso dh token. IBKR attributes it (opens in a new tab) to live and paper details that are not distinct; reset the paper password to a different value.
- Rejected login through a local broker. Clients of an introducing broker must use that broker's own tile.
- Orange D in the order window. Order window data comes from IBKR (opens in a new tab), so data bought from TradingView does not remove it, and each order shows a warning you must confirm until you buy IBKR's data.
- Cannot add a stop or target. IBKR brackets only orders that are still open.
Can TradingView alerts trade on Interactive Brokers automatically?
Not through the broker link, and using a webhook bridge for this conflicts with TradingView's published terms, so read them before building anything.
- Help Center. Automated strategy trading with a brokerage account is not available yet (opens in a new tab), and strategy trading is limited to backtesting mode. The credentials article adds: "Our alerts are not designed for automated trading."
- IBKR. Its FAQ (opens in a new tab) says Pine Script is not supported for trading with IBKR, though it still works for indicators.
- Terms of Use. Section 3 (opens in a new tab) names automated trading and automated order generation as prohibited, bars third parties from offering products that rely on these features or advertise them for such use, and warns of blocking, account termination and legal action.
Webhooks are technically available, and many products use them, but that does not settle the contract question. The rest of this guide describes the engineering for readers who have taken that advice.
The hard parts of a TradingView webhook to IBKR bridge
A webhook is the easy part; the difficulty is that an alert can arrive when no authenticated IBKR session can take it.
| Problem | What the documents say | What the bridge must do |
|---|---|---|
| One session | One brokerage session per username (opens in a new tab) across TWS, Client Portal, mobile and the Web API | Use a dedicated username; market data is charged again for it |
| Restarts | TWS and Gateway are designed to restart daily (opens in a new tab), with a manual login about weekly; /iserver pauses near 01:00 regional time | Refuse or hold alerts in that window, and alert a person |
| No headless login | Neither TWS nor Gateway runs without a GUI, and IBKR does not support automating the gateway login | Plan for a desktop session and a person; this guide offers no workaround |
| Market data | Without IBKR data, TWS may hold an API order until someone clicks Transmit, unless precautions are bypassed (opens in a new tab) | Decide this deliberately, and detect held orders |
| Permissions | Set per security type; a rejection arrives after your webhook reply | Report rejections from error() and orderStatus |
| Duplicates | TradingView resends (opens in a new tab) on 500 to 599, except 504, after 5 seconds, up to 3 times | Filter on an alert ID and store it durably |
| Webhook limits | 3 seconds (opens in a new tab), ports 80 and 443, no IPv6, 2FA required; not on the free plan, per the pricing page (opens in a new tab) | Reply fast; placeOrder does not wait for a fill |
Hypothetical example. An alert fires while IB Gateway restarts and the bridge replies 503. TradingView sends it 3 more times, 5 seconds apart, so the retries end about 15 seconds later. If the restart takes a minute the alert is gone, unless the bridge stored it, and a stored alert needs an age limit so that it cannot fire at a stale price.
Keep the socket private too: only the webhook endpoint faces the internet, and ports such as 4001 and 7496 stay on localhost or trusted IPs.
A tested receiver: from synthetic alert to IBKR order
This code does the IBKR-specific part: it validates an alert, refuses it when the session is down or the alert is stale, filters duplicates and builds a limit order tagged with the alert ID.
The web service around it, durable storage and logging are in TradingView webhook in Python, and the overall design in TradingView webhook bot. Here seen is in memory, so a restart forgets it, which a live bridge must not do. The secret is a random value made for this webhook, never an IBKR login: TradingView warns against (opens in a new tab) putting credentials in webhook messages. Symbol, sizes and limits are placeholders for rules of your own. Setup of the official client is in Interactive Brokers API Python.
import hmac, json, threading, time
from datetime import datetime
from decimal import Decimal, InvalidOperation
from ibapi.client import EClient
from ibapi.contract import Contract
from ibapi.order import Order
from ibapi.wrapper import EWrapper
ALLOWED = {"XYZ": ("STK", "SMART", "USD")} # your own list
MAX_QTY, MAX_PRICE, MAX_AGE_S = Decimal("10"), 1000.0, 60 # your own limits
class Session(EWrapper, EClient):
"""One TWS or IB Gateway session, and whether orders may be sent to it."""
def __init__(self):
EWrapper.__init__(self)
EClient.__init__(self, wrapper=self)
self.next_id, self.up = None, threading.Event()
def nextValidId(self, orderId):
self.next_id = orderId
self.up.set()
def connectionClosed(self):
self.up.clear()
def error(self, reqId, errorTime, errorCode, errorString, advancedOrderRejectJson=""):
if errorCode == 1100: # TWS lost its link to IBKR
self.up.clear()
elif errorCode in (1101, 1102) and self.next_id is not None: # restored
self.up.set()
class Bridge:
def __init__(self, session, secret):
self.session, self.secret = session, secret
self.seen, self.lock = set(), threading.Lock()
def handle(self, body):
"""Returns (HTTP status, reason). TradingView resends on 5xx except 504."""
try:
a = json.loads(body)
key, symbol, side = str(a["alert_id"]), str(a["symbol"]), str(a["side"])
qty, limit = Decimal(str(a["qty"])), Decimal(str(a["limit"]))
if not (key and qty.is_finite() and limit.is_finite()):
raise ValueError
age = time.time() - datetime.fromisoformat(a["sent_at"]).timestamp()
except (ValueError, KeyError, TypeError, InvalidOperation, OSError, OverflowError):
return 400, "bad message"
if not hmac.compare_digest(str(a.get("secret", "")).encode(), self.secret.encode()):
return 401, "bad secret"
if symbol not in ALLOWED or side not in ("BUY", "SELL"):
return 422, "not on the allowlist"
if not 0 < qty <= MAX_QTY or not 0 < float(limit) <= MAX_PRICE:
return 422, "outside your limits"
if abs(age) > MAX_AGE_S:
return 422, "too old" # never fill a stale alert after a restart
with self.lock:
if key in self.seen:
return 200, "duplicate"
if not self.session.up.is_set():
return 503, "no session" # not recorded, so a resend can still act
self.seen.add(key)
order_id = self.session.next_id
self.session.next_id += 1
c = Contract()
c.symbol = symbol
c.secType, c.exchange, c.currency = ALLOWED[symbol]
o = Order()
o.action, o.orderType, o.totalQuantity = side, "LMT", qty
o.lmtPrice, o.tif, o.orderRef = float(limit), "DAY", key
self.session.placeOrder(order_id, c, o)
return 200, f"sent {order_id}"It ran on 5 November 2026 with Python 3.11, the official ibapi 1052.1 client and synthetic alerts posted to a local HTTP handler. Main results:
valid alert -> 200 sent 101
same alert resent -> 200 duplicate
wrong secret -> 401 bad secret
alert 5 minutes old -> 422 too old
not JSON -> 400 bad message
session down (error 1100) -> 503 no session
same alert after 1102 -> 200 sent 102The mock received two orders, 101 and 102, each carrying its alert ID in orderRef. A real session was never touched, so this does not show real rejections, held orders, restarts or TradingView's own delivery. A reply of 200 means only that placeOrder was called, so track what happens next through the callbacks, starting with a paper account.
Can a bridge use someone else's alerts or accounts?
That is a separate legal problem on top of TradingView's terms, so this guide assumes rules you wrote, your own account and a check of your country's rules.
A paid third-party alert feed changes the legal picture. ESMA's briefing of 30 March 2023 (opens in a new tab) (paragraph 12) repeats that a firm's automatic execution of third-party trade signals, with no further client action, counts as portfolio management under MiFID. Serving other people's accounts adds IBKR's third-party approval process (opens in a new tab), which also expects registration or a legal opinion for each region served.
A wrong quantity executes as fast as a right one, automated orders can lose money, and backtests do not guarantee future results. Fincode's general page is TradingView automation; that work runs by default on the customer's own server, from rules the customer wrote, and does not connect paid signal feeds. Naming IBKR here does not mean Fincode integrates it or has built on it. Similar exchange routes are in connect TradingView to exchanges.
Frequently asked questions
Can I connect TradingView to Interactive Brokers for free?
IBKR's pages list no connection fee and ask for an open account funded with at least USD 1. IBKR market data costs extra and needs USD 500 plus the subscription, as read on 5 November 2026. TradingView plans are separate, and webhook alerts need a paid one.
Does Pine Script place orders on IBKR?
No. IBKR's FAQ says Pine Script is not supported for trading with IBKR, though it still works for indicators.
Why do I get logged out of IBKR on TradingView?
A username can hold one brokerage session across IBKR's platforms, so logging in on your phone, in Client Portal or in TWS can end the TradingView session. A second username avoids this, with market data charged again.
Can a TradingView webhook reach TWS directly?
No. A webhook posts to an HTTP endpoint on port 80 or 443, while TWS listens on a socket for API clients. You need a receiver between them, and TradingView's terms should be checked first.
Sources
- TradingView Help Center: How to autotrade using Pine Script strategies (opens in a new tab)
- TradingView Help Center: How to configure webhook alerts (opens in a new tab)
- TradingView Help Center: Webhook resubmission (opens in a new tab)
- TradingView Help Center: Using credentials for webhooks (opens in a new tab)
- TradingView: Plans and pricing (webhook notifications by plan) (opens in a new tab)
- TradingView: Terms of Use, section 3 (opens in a new tab)
- IBKR: TradingView Requirements (opens in a new tab)
- IBKR: Connecting TradingView with Interactive Brokers (opens in a new tab)
- IBKR: TradingView FAQ (Pine Script, sso dh token, brackets) (opens in a new tab)
- IBKR: TradingView Supported Security Types (opens in a new tab)
- IBKR: Market Data at TradingView (opens in a new tab)
- IBKR TWS API: Download TWS or IB Gateway (headless, restarts) (opens in a new tab)
- IBKR: General Third Party FAQ (precautions, Transmit button, weekly login) (opens in a new tab)
- ESMA: Supervisory briefing on copy trading, 30 March 2023 (opens in a new tab)
- SPK (Capital Markets Board): Notice on unauthorized leveraged transactions, 23 February 2023 (Turkish) (opens in a new tab)
This guide is general information about software and markets, not investment, legal or tax advice. Automated trading can lose money, past or backtested performance does not guarantee future results, and the rules that apply depend on your jurisdiction and your exchange's terms. Sources, checks and corrections: see the editorial policy.