TradingView to Zerodha automation

TradingView alerts to Zerodha in 2026

The cleanest setup is not a blind alert-to-order bridge. It is a secure webhook layer that validates TradingView signals before they touch Zerodha Kite Connect.

Summary

  • TradingView sends a webhook alert in JSON.
  • A Python receiver checks the secret, symbol, action, quantity, and trade limits.
  • The receiver calls Zerodha Kite Connect only after the signal passes risk validation.

Recommended architecture

1. TradingView alert

Pine Script or chart alert sends a JSON payload to your webhook URL.

2. Python webhook

FastAPI or Flask validates the payload, blocks duplicates, and logs every decision.

3. Zerodha execution

Kite Connect places the order, then your system stores the order_id and response.

TradingView alert JSON

{
  "secret": "change-this-secret",
  "symbol": "NSE:INFY",
  "side": "BUY",
  "quantity": 1,
  "signal_id": "{{ticker}}-{{interval}}-{{time}}"
}

Python webhook skeleton

from fastapi import FastAPI, HTTPException
from pydantic import BaseModel

app = FastAPI()
ALLOWED_SECRET = "change-this-secret"
ALLOWED_SYMBOLS = {"NSE:INFY": ("NSE", "INFY")}
seen_signals = set()

class Alert(BaseModel):
    secret: str
    symbol: str
    side: str
    quantity: int
    signal_id: str

@app.post("/tradingview")
def tradingview_alert(alert: Alert):
    if alert.secret != ALLOWED_SECRET:
        raise HTTPException(status_code=403, detail="Bad secret")
    if alert.signal_id in seen_signals:
        return {"status": "ignored", "reason": "duplicate"}
    if alert.symbol not in ALLOWED_SYMBOLS or alert.quantity < 1:
        raise HTTPException(status_code=400, detail="Invalid order")

    exchange, tradingsymbol = ALLOWED_SYMBOLS[alert.symbol]
    seen_signals.add(alert.signal_id)
    # Call kite.place_order(...) here after token setup.
    return {"status": "validated", "exchange": exchange, "tradingsymbol": tradingsymbol}

Common setup mistakes

ProblemWhy it hurtsFix
Webhook URL exposedAnyone can send fake ordersUse a secret, IP/rate checks, and server logs.
No duplicate guardRepeated alerts can place repeated ordersStore signal_id and reject repeats.
Raw TradingView symbolsBroker symbols and exchange tokens may differMaintain a symbol map and verify against instruments.
No position checkExit alerts may fire without a positionCheck holdings/positions before exit orders.

FAQ

What is the easiest way to connect TradingView alerts to Zerodha?

Use a TradingView webhook with a Python receiver that validates the alert before calling Kite Connect.

Is a webhook enough by itself?

No. A webhook only transports the message. You still need authentication, duplicate protection, symbol mapping, risk rules, and order logging.

Can this work with Pine Script strategies?

Yes. Pine Script can generate entry and exit alerts, while the Python layer handles broker-specific execution.