Over 70% of TradingView strategy alerts never reach a broker. [needs citation] They fire into the void — a perfectly timed signal that generated zero rupees because there was no pipeline to act on it. Traders spend weeks perfecting their Pine Script logic, then execute manually, miss entries, and blame their strategy.
The real culprit is the missing link: a webhook receiver that takes a TradingView alert, interprets it, and fires a real order to your broker API. OpenAlgo is that link. And once you set it up, your chart does the trading.
TL;DR
- TradingView alerts can POST a JSON payload to any webhook URL when triggered
- OpenAlgo runs locally and exposes a webhook endpoint that receives those payloads
- A correctly formatted JSON message tells OpenAlgo which broker, symbol, action, and quantity to use
- The result: Pine Script alert fires → OpenAlgo receives → broker API executes → order placed, no manual step
Have you ever watched a perfect signal appear on your chart — and then spent 30 seconds fumbling to place the order, only to see the candle already closing?
How the OpenAlgo Webhook Pipeline Works
The pipeline has exactly four steps. Every automation failure you will ever face lives in one of these four boxes.
TradingView generates an alert based on your Pine Script condition. That alert includes a webhook URL and a message body you define. TradingView's servers POST that message to the URL. OpenAlgo — running on your machine or a server — receives the POST, parses the JSON, authenticates it, and calls your broker's API with the order details. The broker executes the order.
That is the entire system. No third-party service. No subscription. No middleman taking a cut of your latency.
| Step | What Happens | Who Does It |
|---|---|---|
| 1. Alert triggers | Pine Script condition evaluates true on bar close (or in real-time) | TradingView cloud |
| 2. Webhook POST | TradingView sends HTTP POST with your JSON payload to your URL | TradingView servers |
| 3. Order parsing | OpenAlgo receives, validates, and translates the JSON to a broker order | OpenAlgo (local/server) |
| 4. Broker execution | Order is placed via the broker's official API | Your broker (Zerodha, Fyers, AngelOne, Upstox, etc.) |
The critical thing to understand: steps 1 and 2 happen on TradingView's infrastructure. You control steps 3 and 4. This means your OpenAlgo endpoint must be reachable from the public internet — which we will cover in the setup section.
If TradingView is doing the heavy lifting on signal generation, why do most webhook setups fail? Almost always, it is a misconfiguration on the OpenAlgo side — wrong URL, bad JSON, or a field name typo. Ready to make sure yours works?
Setting Up Your Pine Script Alert Message
This is where most traders get it wrong. The TradingView alert message is not just a text notification — it is the JSON payload that OpenAlgo reads to build your order. Every field must match exactly what OpenAlgo expects.
Here is a complete Pine Script v6 example with a simple EMA crossover strategy that sends a webhook alert:
pine//@version=6 strategy("EMA Crossover — OpenAlgo Webhook", overlay=true, default_qty_type=strategy.fixed, default_qty_value=1) fastLen = input.int(9, "Fast EMA") slowLen = input.int(21, "Slow EMA") fastEMA = ta.ema(close, fastLen) slowEMA = ta.ema(close, slowLen) longCondition = ta.crossover(fastEMA, slowEMA) shortCondition = ta.crossunder(fastEMA, slowEMA) // Strategy entries (for backtesting) if longCondition strategy.entry("Long", strategy.long) if shortCondition strategy.entry("Short", strategy.short) // Alert message — this is the JSON payload sent to OpenAlgo // In the TradingView alert dialog, paste this into the "Message" field: // // { // "apikey": "YOUR_OPENALGO_API_KEY", // "strategy": "EMA_Crossover", // "symbol": "RELIANCE", // "action": "{{strategy.order.action}}", // "exchange": "NSE", // "pricetype": "MARKET", // "product": "MIS", // "quantity": "1", // "position_size": "{{strategy.position_size}}" // }
What each field does:
apikey— Your OpenAlgo API key (generated in the OpenAlgo dashboard). This authenticates the request. Never expose this in a public script.strategy— A label you choose. Useful for logging and identifying which strategy fired.symbol— The trading symbol as your broker recognises it (e.g.RELIANCE,NIFTY24DEC25000CE). Check your broker's symbol list in OpenAlgo.action—BUYorSELL. Using{{strategy.order.action}}lets TradingView populate this dynamically based on which strategy entry fired.exchange—NSE,BSE,NFO,MCX, etc.pricetype—MARKET,LIMIT,SL, orSL-Mdepending on your order type.product—MIS(intraday) orCNC(delivery) orNRML(for F&O overnight).quantity— Number of shares or lots. Keep this as a string.position_size— Optional but useful for logging. Tracks net position in the strategy.
You paste the JSON block (without the Pine Script comment markers) directly into the TradingView alert's Message field when creating the alert. TradingView will substitute the {{...}} variables at alert-fire time.
Common Mistake: Wrong field names and missing apikey
OpenAlgo's webhook endpoint is case-sensitive and schema-strict. "Action" is not the same as "action". "Symbol" will fail where "symbol" is required. The most common reason orders never fire: a field name with a capital letter, a trailing comma after the last JSON field (invalid JSON), or forgetting to include "apikey" entirely. Always validate your JSON at jsonlint.com before going live. Also: your apikey value must match exactly what is shown in your OpenAlgo dashboard — no spaces, no quotes around it in the wrong place.
Before you wire up the webhook, ask yourself: do you know what symbol name your broker uses for the instrument you want to trade? A mismatch here silently fails — OpenAlgo will reject the order.
Configuring OpenAlgo to Receive the Webhook
Assuming you have OpenAlgo installed (see the Getting Started guide if not), here is how to configure it to receive TradingView webhooks.
- Start OpenAlgo. Run
python app.pyfrom your OpenAlgo directory. The service starts onhttp://localhost:5000by default. - Generate your API key. Open the OpenAlgo web dashboard at
http://localhost:5000. Navigate to API Keys and generate a new key. Copy it — this goes into your Pine Script payload as"apikey". - Make OpenAlgo publicly accessible. TradingView's servers need to reach your webhook endpoint. If OpenAlgo is running on your local machine, use ngrok or Cloudflare Tunnel to expose it. Run
ngrok http 5000and copy the generated HTTPS URL (e.g.https://abc123.ngrok.io). For production, deploy OpenAlgo on a VPS (DigitalOcean, AWS Lightsail, or a ₹500/month Indian VPS) so the endpoint is always up. - Note your webhook endpoint. The OpenAlgo webhook URL is:
https://YOUR_PUBLIC_URL/api/v1/placesmartorder— this is the URL you paste into TradingView's alert webhook field. - Create the TradingView alert. In TradingView, right-click on your chart or open the Alerts panel. Set your alert condition (or use a strategy alert). In the Webhook URL field, paste your OpenAlgo endpoint. In the Message field, paste your JSON payload (from the Pine Script section above, without the comment markers).
- Test with a manual trigger. Before running live, use a tool like Hoppscotch or
curlto POST a sample JSON payload to your endpoint and confirm OpenAlgo receives it and logs the order attempt. - Check the OpenAlgo logs. Every incoming webhook request is logged. If something fails, the log tells you exactly what went wrong — bad JSON, unrecognised symbol, authentication failure, or broker API error.
Pro Tip: Always test in paper trading mode first
OpenAlgo supports a paper trading mode that simulates order placement without touching your broker account. Set PAPER_TRADE=True in your OpenAlgo config before you run any live webhook test. Fire a few alerts, verify the order details appear correctly in the logs, then — and only then — switch to live mode. A five-minute paper test has saved more than a few traders from a misplaced market order on a Friday afternoon.
Real Tradeoffs
No system is perfect. Here are the three most important tradeoffs you will face with this setup, and when each one will bite you.
| Tradeoff | What It Means | When It Fails |
|---|---|---|
| Local machine vs. VPS | Running on your laptop is free but depends on your internet and machine being on. A VPS costs ₹400–800/month but is always available. | Your laptop sleeps, your router drops, or load-shedding hits — alert fires, OpenAlgo is offline, order never reaches broker. |
| Market orders vs. limit orders | Market orders execute immediately but at whatever price is available. Limit orders control slippage but may not fill. | In fast-moving markets (earnings, macro events, Option expiry), a market order on an illiquid strike can fill at a terrible price. A limit order may simply not fill at all. |
| Single-legged vs. multi-legged strategies | A simple BUY/SELL webhook is easy to set up. Spreads, hedges, and bracket orders require more complex payloads and OpenAlgo's smart order features. | You automate a leg-1 entry but forget leg-2 — now you have a naked position you did not intend. Always map out the full order lifecycle before automating. |
How much downtime can your strategy tolerate? A momentum strategy that misses a 9:15 AM entry because OpenAlgo was offline is very different from a weekly options strategy where timing is less critical — which one describes your use case?
And more practically: are you comfortable with fully automated execution, or do you want a human in the loop for confirmation before orders fire?
Choose Your Scenario
Scenario A: You Want Fully Automated Execution
You want Pine Script to fire, OpenAlgo to receive, and the broker to execute — zero human steps. This is the full algo trading dream.
What you need:
- OpenAlgo running 24/7 on a VPS or always-on machine
- A reliable ngrok alternative or a static public IP (Cloudflare Tunnel is free and stable)
- Paper-tested JSON payloads with correct field names and symbols
- A strategy that has been backtested and forward-tested on paper before going live
- Broker API with sufficient margin and correct product type (MIS for intraday, NRML for F&O)
Best for: Intraday momentum strategies, options selling setups, EMA crossover systems on liquid NSE stocks, scalping bots on Nifty futures.
Risk checkpoint: Set position size limits inside OpenAlgo and at the broker level. One rogue alert should not be able to blow your account.
Scenario B: You Want Semi-Automated With Manual Confirmation
You want TradingView to notify you when a signal fires, and you decide whether to act. No auto-execution.
What you need:
- TradingView alert set to send a notification (push, email, or SMS) instead of — or in addition to — a webhook
- Optionally: OpenAlgo configured to log the signal but not place an order (you can build this with a custom endpoint or use OpenAlgo's logging mode)
- A manual order placement workflow in your broker app
Best for: Swing traders who want signal discipline without full automation, traders new to algo trading who want to verify signals match their thesis before committing capital, strategies on less-liquid stocks where manual execution is safer.
Upgrade path: Start with Scenario B for 30 days. If you find yourself placing the order every time the alert fires without second-guessing it, you are ready for Scenario A.
5-Minute Decision Framework
Use this flowchart every time your webhook setup is not working:
Work through this top to bottom before posting in forums or assuming your strategy does not work. The answer is almost always at node F or G.
The Worst Mistake: Running live without paper trading first
Every week, someone in an algo trading community posts a screenshot of an order for 1,000 quantities instead of 1 — or a buy when they meant to sell — or an order placed at 9:15 AM in a stock that was circuit-filtered. All of these were preventable with one step: paper trading. OpenAlgo's paper mode is there for a reason. Use it for at least a full week of market hours before switching PAPER_TRADE to False. If your strategy has a daily loss limit, configure it. If your broker has an order rate limit (most do — typically 10–20 orders per second), make sure your strategy respects it. Going live without this validation is not bold. It is expensive.
Mini-Exercise: Build Your Own Webhook Payload
Fill in the blanks in this template with your own strategy details. This becomes your actual TradingView alert message.
json{ "apikey": "PASTE_YOUR_OPENALGO_API_KEY_HERE", "strategy": "YOUR_STRATEGY_NAME", "symbol": "YOUR_SYMBOL_HERE", "action": "{{strategy.order.action}}", "exchange": "NSE_OR_BSE_OR_NFO", "pricetype": "MARKET", "product": "MIS_OR_CNC_OR_NRML", "quantity": "1" }
Checklist before saving your alert:
- Replace
YOUR_OPENALGO_API_KEY_HEREwith your actual key from the OpenAlgo dashboard - Replace
YOUR_SYMBOL_HEREwith the exact symbol your broker uses (check OpenAlgo's symbol search) - Choose the right
exchange— equity on NSE/BSE, derivatives on NFO, commodity on MCX - Choose the right
product—MISfor intraday (auto-squared off),CNCfor delivery equity,NRMLfor F&O overnight - Validate the JSON at jsonlint.com — no trailing commas, no missing quotes
- Test with a manual POST before creating the live alert
Once your payload is working — what is the first strategy you are going to automate? A simple moving average crossover to start, or something more complex?
And when it fires that first real order automatically at 9:16 AM while you are drinking coffee, what will you do with the time you just got back?
Image Briefs
<!-- IMAGE BRIEF 1
Objective: Show the full TradingView to broker pipeline visually so readers immediately grasp the system architecture
Scene: A clean technical flow diagram showing TradingView chart on the left, an arrow labelled "Webhook POST" pointing to an OpenAlgo server icon in the center, and a broker terminal icon on the right labelled "Order Executed". Indian rupee symbol visible on the broker end. Dark background, neon green and blue accent lines.
Style: Clean tech diagram, flat vector illustration
Key elements: TradingView logo placeholder, webhook arrow with "JSON payload" label, OpenAlgo logo/icon, broker API icon, order confirmation checkmark, NSE/BSE label
Aspect ratio: 16:9
Generation prompt: "Clean flat vector diagram on dark navy background, showing left-to-right data flow: TradingView chart interface icon with green candle chart, arrow labeled 'Webhook POST + JSON', server icon labeled 'OpenAlgo', arrow labeled 'Broker API Call', terminal icon labeled 'Order Filled', neon green and electric blue color scheme, minimal sans-serif labels, tech startup aesthetic, no people"
Alt text: "Diagram showing the four-step pipeline from TradingView alert to OpenAlgo webhook receiver to broker API order execution"
-->
<!-- IMAGE BRIEF 2
Objective: Illustrate the TradingView alert creation dialog so readers know exactly where to paste the webhook URL and JSON payload
Scene: A realistic mockup of the TradingView Create Alert dialog box, with the Webhook URL field highlighted in yellow and a JSON payload visible in the Message field. Clean, bright UI screenshot style.
Style: Photo-realistic UI mockup / screenshot illustration
Key elements: TradingView alert dialog UI elements, Webhook URL input field highlighted, Message textarea with JSON visible, "Create" button, condition fields showing "EMA crossover"
Aspect ratio: 16:9
Generation prompt: "Realistic UI mockup of a dark-themed trading platform alert creation dialog box, fields for 'Condition', 'Webhook URL' highlighted in yellow glow, 'Message' textarea containing JSON code snippet, professional software interface design, dark gray background, subtle blue accents, no real logos, clean typography"
Alt text: "TradingView Create Alert dialog showing the Webhook URL field and JSON payload message field where OpenAlgo connection details are entered"
-->
<!-- IMAGE BRIEF 3
Objective: Show a developer or trader at a desk with a live trade executing automatically — conveying the "set it and forget it" feeling
Scene: A young Indian trader sitting at a dual-monitor setup. One screen shows a TradingView chart with a green arrow signal. The other screen shows an OpenAlgo terminal log with "Order Placed: BUY RELIANCE 1 @ MARKET" in green text. A coffee mug is on the desk. The trader looks relaxed, not frantically clicking.
Style: Photo-realistic illustration, warm ambient lighting, modern home office
Key elements: Dual monitors, TradingView chart with signal, OpenAlgo terminal log, coffee mug, relaxed trader posture, Indian context (kurta or casual modern wear)
Aspect ratio: 16:9
Generation prompt: "Young South Asian man sitting relaxed at a modern home office desk with two monitors, left monitor showing a stock chart with a green upward arrow signal, right monitor showing a terminal window with green text 'Order Placed: BUY @ MARKET', coffee mug on desk, warm ambient lighting, photorealistic digital illustration, hopeful and calm mood, no text overlays on face"
Alt text: "Young trader relaxing at a dual-monitor setup while an automated OpenAlgo webhook fires a real broker order from a TradingView Pine Script alert"
-->
Keep Learning
Ready to go deeper? Here is a structured reading path:
- Next read: Pine Script v6 Alerts & OpenAlgo: The Complete Tutorial — for mastering the alert message format, dynamic variables, and multi-condition alerts
- After that: Build a No-Code Trading Pipeline with n8n + OpenAlgo — automate order logging, Telegram notifications, and Google Sheets dashboards without writing a line of code
- Deeper: Python Backtesting with vectorbt: NSE Futures in 50 Lines — validate your strategy on historical NSE data before you risk a single rupee live
Want the full setup condensed onto one page?
Download the OpenAlgo Webhook Quickstart Checklist — a free one-page PDF with every step from this post, the complete JSON template, a field-by-field reference, and the 10 most common errors with fixes. Bookmark it, print it, tape it next to your monitor. Get the PDF checklist → (coming soon — drop your email in the comments and I will send it directly)
Drop a comment: What broker are you using with OpenAlgo, and what is the first strategy you are automating? Name the broker + strategy type (e.g. momentum, mean-reversion, options selling) — I will feature the most interesting setups in a follow-up post. The best ones get a full breakdown.
FAQ
1. Does TradingView's free plan support webhooks?
No. Webhooks require a TradingView paid plan — Essential or higher. The Essential plan (approximately ₹1,500/month billed annually) is the minimum tier that unlocks the Webhook URL field in the alert dialog. If you see the Webhook URL field greyed out, you are on the free plan.
2. Can OpenAlgo receive webhooks if I am running it on my laptop?
Yes, but your laptop must be on and connected to the internet whenever you expect alerts to fire. TradingView's servers need a publicly reachable URL — which means you need ngrok, Cloudflare Tunnel, or a similar tool to expose your local port. For anything beyond testing, a VPS is strongly recommended.
3. Which Indian brokers does OpenAlgo support for webhook-based order placement?
OpenAlgo supports a wide range of Indian brokers including Zerodha (Kite Connect), Fyers, AngelOne, Upstox, IIFL, Dhan, Firstock, Shoonya, Paytm Money, and several others. The broker list grows with community contributions. Check the OpenAlgo GitHub repository for the current supported broker list.
4. What happens if TradingView fires an alert but OpenAlgo is offline?
The order is lost. TradingView sends the webhook POST once. If OpenAlgo does not respond (because it is offline, the URL is wrong, or the endpoint is unreachable), TradingView marks the alert as failed and moves on. There is no retry queue in the basic setup. This is the primary reason to run OpenAlgo on a VPS rather than a local machine for production strategies.
5. Is this legal and compliant with SEBI regulations for algo trading in India?
OpenAlgo connects to your broker via the broker's official API, using your own credentials. You are the registered client placing orders through an authorised channel. SEBI's algo trading guidelines primarily regulate algo trading offered by brokers to clients as a product — personal algo trading via your own API key sits in a different category. That said, regulations evolve. Consult a SEBI-registered advisor or your broker's compliance team if you are trading at scale or running strategies for others. This post is educational only and not financial or legal advice.
Do This Next
- Install OpenAlgo and confirm it starts without errors on your machine
- Generate your OpenAlgo API key from the dashboard
- Expose your local OpenAlgo endpoint using ngrok or Cloudflare Tunnel and copy the public HTTPS URL
- Write your JSON webhook payload using the mini-exercise template above and validate it at jsonlint.com
- Create a TradingView alert on your strategy with the webhook URL and JSON message — set it to paper trading mode first
- Fire a test alert manually and confirm the order appears in OpenAlgo logs with correct symbol, action, and quantity
- Switch to live mode only after at least one full week of successful paper trading results
Be the first to comment