You don't need to know Python to automate your trading. You need to know how to connect boxes.
That sentence will annoy some developers. It's true anyway. The actual barrier to algorithmic trading for most retail traders is not the inability to write a for loop or call a REST API — it's the inability to visualise the data flow. Which system sends what, to where, in what format, and what happens when it breaks? Once you can draw that on a whiteboard, the tools to implement it are simpler than ever. n8n is a visual workflow builder that turns those whiteboard boxes into real, executable nodes. OpenAlgo is the broker-agnostic order layer that converts a clean JSON payload into a live order on Zerodha, Fyers, Angel, or any of the other Indian brokers it supports. Put them together and you have an automation pipeline that a spreadsheet-literate trader can build, test, and run — without writing a single line of Python.
TL;DR
- TradingView fires an alert with a JSON payload → n8n receives it via a webhook node and validates it
- n8n calls the OpenAlgo API with a structured order payload, which routes the trade to your broker
- Every trade is logged to Google Sheets automatically — your built-in audit trail and debugging tool
- A Telegram notification confirms every order (or every failure) within seconds of execution
Before we go further: if your TradingView strategy fired a perfect signal at 9:32 AM today, what would actually happen? Would an order get placed — or would the signal quietly expire into a notification you'd read at lunch? Sit with that for a moment. The gap between signal and execution is where most retail traders leak returns.
What You'll Build
By the end of this tutorial, you will have a live, working pipeline that does the following without any human intervention: a TradingView alert fires on your chart, a JSON payload arrives at an n8n webhook URL, n8n validates the payload (checking a secret token and market hours), sends a structured order to OpenAlgo, OpenAlgo forwards the order to your broker, and the result — success or failure — gets logged to a Google Sheet and pushed to your phone via Telegram.
Here is the full pipeline at a glance:
| Step | Tool | What it does | Time to set up |
|---|---|---|---|
| 1 | TradingView | Fires an alert with a JSON payload when your strategy condition triggers | Already done — this is your signal source |
| 2 | n8n Webhook Node | Receives the HTTP POST from TradingView and makes the data available to the workflow | 5 minutes |
| 3 | n8n IF Node (token check) | Validates the secret token header to reject unauthorised requests | 2 minutes |
| 4 | n8n IF Node (market hours) | Checks whether the current IST time falls within trading hours before proceeding | 3 minutes |
| 5 | n8n HTTP Request Node | Sends a correctly formatted JSON order payload to the OpenAlgo API | 10 minutes |
| 6 | n8n Google Sheets Node | Appends a row to your trade log with timestamp, symbol, action, quantity, and status | 5 minutes |
| 7 | n8n Telegram Node | Sends a confirmation or error message to your phone instantly | 5 minutes |
Total: roughly 30 minutes the first time. 10 minutes for every workflow after that once you have the pattern.
<!-- IMAGE BRIEF 1: A clean diagram showing the 7-step pipeline as connected boxes — TradingView → n8n Webhook → Token Check → Market Hours Check → OpenAlgo API → Google Sheets + Telegram. Use a dark background with orange/amber accent lines. Label each arrow with the data type being passed (JSON payload, order payload, confirmation, row append, Telegram message). Include the OpenAlgo logo and n8n logo in their respective nodes. Dimensions: 1200×600px. -->
Question: which of those 7 steps do you already have working today? Identify the first gap — that is the only thing you need to solve right now.
Step 1 — Install n8n (Self-Hosted or Cloud)
You have two choices. One is faster to start. The other is cheaper and more private. Neither requires you to write any application code.
Option A: n8n Cloud (recommended for beginners)
Go to n8n.cloud and sign up for a free trial. You get a hosted n8n instance with a public URL, SSL already configured, and no server management. The free tier covers enough executions to build and test this workflow. When you graduate to live trading, the Starter plan at around $20/month is more than sufficient for a trading workflow that fires 10–50 times per day.
Pros of cloud: Zero infrastructure to manage. Your webhook URLs are publicly accessible immediately. Automatic updates and uptime monitoring.
Cons of cloud: You are trusting a third party with your workflow logic and API credentials. Execution limits apply on lower tiers. Less control over latency.
Option B: Self-Hosted with Docker (recommended for privacy-conscious traders)
If you have a VPS (a DigitalOcean Droplet or AWS Lightsail instance at $6–12/month works perfectly), you can run n8n yourself with a single command:
bashdocker run -it --rm \ --name n8n \ -p 5678:5678 \ -v ~/.n8n:/home/node/.n8n \ docker.n8io/n8n
For a production setup that survives reboots, use docker-compose with a .env file for your N8N_BASIC_AUTH_USER, N8N_BASIC_AUTH_PASSWORD, and your WEBHOOK_URL (the public URL of your VPS). The n8n documentation has a complete docker-compose.yml you can copy directly.
Pros of self-hosted: All credentials and workflow data stay on your server. No execution limits. Lower ongoing cost.
Cons of self-hosted: You manage uptime, SSL certificates (use Caddy or Nginx with Let's Encrypt), and updates. A brief server outage means missed signals during that window.
For this tutorial, either option works identically. The n8n UI is the same in both cases.
Step 2 — Create the Webhook Node in n8n
The webhook node is the front door of your workflow. TradingView will knock on this door every time an alert fires.
- Open your n8n instance and click New Workflow.
- Click the + button to add a node, then search for Webhook and select it.
- In the node settings panel, set HTTP Method to
POST. - Set Path to something specific to this workflow, for example
trading-signal. Avoid generic paths likewebhookortest. - Set Response Mode to
Respond Immediately— TradingView doesn't wait for a complex response and will time out if you try to send one after processing. - Click Execute Node to activate the webhook in test mode. n8n will display a test URL in this format:
https://your-n8n-instance.com/webhook-test/trading-signal
When you go live (activate the workflow), the URL changes to:
https://your-n8n-instance.com/webhook/trading-signal
- To test your webhook, use Postman or the command line to send a sample payload:
bashcurl -X POST https://your-n8n-instance.com/webhook-test/trading-signal \ -H "Content-Type: application/json" \ -H "X-Alert-Token: your_secret_token_here" \ -d '{ "symbol": "NIFTY", "exchange": "NFO", "action": "BUY", "quantity": "50", "product": "MIS", "pricetype": "MARKET", "price": "0", "trigger_price": "0", "strategy": "EMA_Crossover" }'
If the webhook node receives the request, it will show you the parsed JSON in the output panel. You now have data flowing into your workflow.
Common mistake: exposing your webhook URL without authentication.
Your n8n webhook URL, once active, accepts POST requests from anyone on the internet who knows the URL. Without validation, a malformed or malicious request could trigger an unintended order. The very first node after your webhook should be an IF node that checks for a secret token header. In the TradingView alert message, include a header key (for example X-Alert-Token) with a long, random string value. In n8n, check that {{ $request.headers['x-alert-token'] }} equals your expected token. If it does not match, route the workflow to a Stop and Error node. This takes two minutes to add and protects your pipeline from spurious triggers.
Step 3 — Add the OpenAlgo HTTP Request Node
Once your webhook has received and validated a signal, you need to forward it as a properly formatted order to OpenAlgo.
Add an HTTP Request node after your validation IF node. Configure it as follows:
- Method:
POST - URL:
http://127.0.0.1:5000/api/v1/placeorder(if OpenAlgo is running on the same machine as n8n) or the IP/domain of your OpenAlgo server - Authentication: None (OpenAlgo uses an API key in the request body)
- Body Content Type:
JSON
In the Body section, enter this JSON structure and use n8n expressions to map the incoming webhook data to the OpenAlgo fields:
json{ "apikey": "your_openalgo_api_key", "strategy": "{{ $json.strategy }}", "symbol": "{{ $json.symbol }}", "action": "{{ $json.action }}", "exchange": "{{ $json.exchange }}", "pricetype": "{{ $json.pricetype }}", "product": "{{ $json.product }}", "quantity": "{{ $json.quantity }}", "price": "{{ $json.price }}", "trigger_price": "{{ $json.trigger_price }}" }
The {{ $json.fieldname }} syntax is how n8n references data from previous nodes. When the webhook receives the TradingView payload, every field in that JSON becomes available as $json.fieldname in all subsequent nodes. You are not writing code — you are referencing a box by its label.
A note on the OpenAlgo API key: generate this inside the OpenAlgo dashboard under Settings. Treat it like a password. Store it in n8n as a Credential (use the built-in Credentials manager, not a hardcoded string in the workflow JSON) so it is encrypted at rest and never exposed in exported workflow files.
A note on paper trading: OpenAlgo has a paper trading mode that logs orders to a local database without sending them to your broker. Enable it in your OpenAlgo config before you connect this pipeline to a live account. Every response from the OpenAlgo API in paper mode looks identical to a live response — same JSON structure, same status codes — so your n8n workflow logic can be fully tested without risking capital.
Question: what is the one field in your TradingView alert payload that you are least confident about getting right — symbol format, exchange code, or quantity? Identify it now, before you go live.
Step 4 — Log Every Trade to Google Sheets
Add a Google Sheets node after the HTTP Request node. This log is not optional. It is your compliance record, your debugging tool, and the first place you look when something goes wrong at 10:15 AM on an expiry day.
Setup:
- Authenticate the Google Sheets node with your Google account via the built-in OAuth flow in n8n.
- Create a new Google Sheet with the following column headers in row 1:
Timestamp,Symbol,Exchange,Action,Quantity,Price Type,Product,Strategy,OpenAlgo Response,Status. - In the Google Sheets node, set Operation to
Append Row. - Map each column to its corresponding data field using n8n expressions:
| Sheet Column | n8n Expression |
|---|---|
| Timestamp | {{ $now.toISO() }} |
| Symbol | {{ $('Webhook').item.json.symbol }} |
| Exchange | {{ $('Webhook').item.json.exchange }} |
| Action | {{ $('Webhook').item.json.action }} |
| Quantity | {{ $('Webhook').item.json.quantity }} |
| Price Type | {{ $('Webhook').item.json.pricetype }} |
| Product | {{ $('Webhook').item.json.product }} |
| Strategy | {{ $('Webhook').item.json.strategy }} |
| OpenAlgo Response | {{ JSON.stringify($json) }} |
| Status | {{ $json.status }} |
Note that for columns sourcing from the webhook node (rather than the HTTP Request node), you need to explicitly reference the Webhook node by name: $('Webhook').item.json.fieldname. This is because by the time the Google Sheets node runs, the "current" $json context points to the OpenAlgo API response, not the original webhook payload.
Pro tip: filter by market hours before you ever reach the OpenAlgo node.
Add an IF node immediately after the token validation check. Use n8n's DateTime functions to evaluate whether the current time in IST falls within the trading window. The expression looks like this:
{{ $now.setZone('Asia/Kolkata').hour >= 9 && ($now.setZone('Asia/Kolkata').hour < 15 || ($now.setZone('Asia/Kolkata').hour === 15 && $now.setZone('Asia/Kolkata').minute <= 30)) }}
If this evaluates to false, route the workflow to the Google Sheets node directly (log the signal as "Received outside market hours") and skip the OpenAlgo call entirely. This prevents accidental pre-market or post-market orders, and ensures your log captures every signal even when the order is intentionally not placed.
Step 5 — Telegram Notification Node
A trade that fires and logs silently is a trade you might not notice has gone wrong for 20 minutes. Telegram fixes this. Add a Telegram node as the final step in both the success path and the error path of your workflow.
Setting up a Telegram bot in 5 minutes
- Open Telegram and search for @BotFather.
- Send
/newbot, then follow the prompts: give your bot a name (e.g.,MyTradingBot) and a username (e.g.,my_trading_alerts_bot). - BotFather will reply with your bot token — a string that looks like
7123456789:AAFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. Save this. - Start a conversation with your new bot (search for it by username and click Start).
- To get your chat ID, send any message to the bot, then visit
https://api.telegram.org/bot<your_token>/getUpdatesin a browser. Look for"chat":{"id":XXXXXXXXX}in the response. That number is your chat ID.
Configuring the Telegram node in n8n
- Add a Telegram node. Create a Telegram credential using your bot token.
- Set Chat ID to your personal chat ID.
- Set Text to a message that gives you everything you need at a glance:
{{ $('Webhook').item.json.action }} {{ $('Webhook').item.json.quantity }} {{ $('Webhook').item.json.symbol }}
Exchange: {{ $('Webhook').item.json.exchange }}
Strategy: {{ $('Webhook').item.json.strategy }}
Status: {{ $json.status }}
Time: {{ $now.setZone('Asia/Kolkata').toFormat('HH:mm:ss') }} IST
- Add a second Telegram node on the error branch of your workflow (connected from the IF node that handles OpenAlgo API failures) with a message like:
ORDER FAILED
{{ $('Webhook').item.json.action }} {{ $('Webhook').item.json.symbol }}
Error: {{ $json.message }}
Check Sheets log immediately.
You now receive an instant mobile notification for every order placement attempt, successful or not.
<!-- IMAGE BRIEF 2: A side-by-side screenshot mockup showing the n8n workflow canvas on the left (with visible nodes: Webhook → IF (token) → IF (hours) → HTTP Request → Google Sheets, with a Telegram node branching from both the success and error outputs of the HTTP Request node) and a Telegram chat on the right showing a formatted trade confirmation message. Use realistic-looking UI elements. Dimensions: 1400×700px. -->
Real Tradeoffs
No tool is perfect. Before you commit to this stack, understand what you are choosing and what you are giving up.
| Comparison | Winner for trading | Why |
|---|---|---|
| n8n self-hosted vs n8n cloud | Self-hosted for serious traders | API keys stay on your infrastructure; no execution throttling; lower latency to OpenAlgo if co-located |
| n8n vs Zapier/Make for trading | n8n by a wide margin | Zapier and Make have no native webhook-to-HTTP-request flow for financial APIs without expensive workarounds; n8n's expression engine handles JSON nesting that breaks Make's mapping UI; n8n has no per-task pricing that punishes high-frequency signals |
| No-code pipeline vs Python script | Depends on your skill ceiling | n8n wins on time-to-live and maintainability for non-coders; Python wins on conditional complexity (multi-leg orders, dynamic position sizing from portfolio state, real-time risk checks) — but a Python script requires a server, a process manager, error handling, and logging that n8n gives you for free |
Question: what is the single most important failure mode you want this system to handle — unexpected webhook, order rejection, network timeout, or something else?
Question: if this pipeline fired an order at the wrong time tomorrow, what would it cost you — and does your risk management allow for that?
Choose Your Scenario
Not every trader wants the same level of automation. Here are the two configurations you should choose between before you activate anything on a live account.
Scenario A: Fully Automated Execution
Alert fires. Order placed. No human in the loop.
This is the correct setup if your strategy fires on bar close (not repaints), you have backtested for at least 6 months of out-of-sample data, your position size is fixed and does not depend on portfolio state, and you are comfortable with the maximum single-trade loss your quantity implies.
In this configuration, the n8n workflow runs to completion automatically: Webhook → validate → market hours check → OpenAlgo → Sheets → Telegram. You see the Telegram notification after the order is already placed.
Best suited for: momentum strategies on liquid instruments (Nifty Futures, Bank Nifty, large-cap equities) with well-defined entries and stops. Intraday MIS orders where the broker auto-squares off at 3:20 PM reduce overnight risk.
Scenario B: Semi-Automated with Telegram Approval
Alert fires. You get a Telegram notification. You tap Approve before the order goes.
This is the correct setup if you want to review signals before execution, if your strategy is still in validation and you want to veto certain setups, or if the psychological cost of "algo traded while I wasn't watching" is too high for you right now.
In this configuration, you add a Wait node after the market hours check. The Wait node pauses the workflow and sends a Telegram message with an inline keyboard that has two buttons: Approve and Reject. When you tap Approve, the workflow resumes and calls OpenAlgo. When you tap Reject, the workflow logs the skipped signal and ends.
This approach requires n8n's Webhook node used as a resumption endpoint (n8n supports this natively with the Wait node's webhook resume feature). The setup takes an extra 15 minutes but gives you a human checkpoint that is faster than any manual entry while still being automated.
Best suited for: traders who want the speed of automated order entry (sub-second from approval tap to order) without giving up discretion over which signals to act on.
5-Minute Workflow Design Framework
Before you build anything in n8n, draw this flow on paper or in a notes app. Then map each box to an n8n node. The Mermaid diagram below is the exact flow this tutorial implements:
Every node in this diagram corresponds to a named node in n8n. The conditional branches ({...}) are IF nodes. The action boxes are Webhook, HTTP Request, Google Sheets, and Telegram nodes. Nothing in this diagram requires code. It requires judgment about what should happen at each decision point — and that judgment is yours, not the tool's.
Never run this pipeline on a live broker account without first completing at least two weeks of paper trading.
OpenAlgo's paper trading mode is not a simulation — it runs the exact same API validation, order construction, and response handling as the live mode, with the sole difference being that no order reaches the exchange. Two weeks of paper trading will surface broken field mappings, timezone edge cases at market open/close, network timeout handling gaps, and signal quality issues that no amount of pre-launch testing reveals. Skipping paper trading to "save time" is how traders place 50 unintended orders in a burst because a field mapping was wrong and the workflow looped. This is not hypothetical.
<!-- IMAGE BRIEF 3: An annotated screenshot of an n8n workflow canvas showing the complete 7-node workflow described in this post. Each node should be visible with its label: "TradingView Webhook", "Token Check (IF)", "Market Hours (IF)", "Place Order (HTTP Request)", "Log to Sheets (Google Sheets)", "Notify Success (Telegram)", "Notify Failure (Telegram)". Highlight the two Telegram nodes with a dashed orange border to indicate they are on different branches. Show connecting lines between all nodes. Dimensions: 1400×800px. -->
Mini-Exercise
Fill in this template before you build anything. Do it in your notes app right now. Completing this template is the design phase of your workflow — it takes 5 minutes and saves you an hour of debugging later.
My TradingView alert sends: [describe the JSON fields your Pine Script alert message contains — symbol, action, quantity, exchange, etc.]
My n8n webhook URL: [your-n8n-instance-url]/webhook/[your-chosen-path]
My OpenAlgo endpoint: [http://your-openalgo-ip:5000/api/v1/placeorder OR /api/v1/placesmartorder]
My Google Sheets log columns: [Timestamp], [Symbol], [Action], [Quantity], [Status], and [what else?]
My Telegram bot token: [set up — paste the BotFather token here temporarily, then move it to n8n Credentials]
I will test in paper mode for [?] days before switching to live.
The maximum loss I am comfortable with per signal, given my quantity setting: ₹[?]
The signal I am automating comes from: [strategy name, timeframe, instrument]
Do not skip the last two fields. The maximum-loss figure forces you to verify your quantity before the pipeline goes live. The strategy description reminds you, three months from now, why this workflow exists.
Question: what is the one part of this workflow you are most likely to skip in the interest of "getting it working faster" — and what is the realistic worst-case if you skip it?
Question: in Scenario A (fully automated), who do you trust more to execute this strategy consistently — yourself or the workflow? Be honest. The answer changes your configuration.
Lead Magnet — n8n Trading Workflow Templates Pack
Building from scratch takes time. To get you to a working pipeline faster, the templates pack includes three ready-to-import n8n workflow JSON files:
Template 1: Basic Alert-to-Order
Webhook → token check → OpenAlgo HTTP Request. Minimal setup, maximum speed. Import, add your OpenAlgo API key, and test in paper mode in under 10 minutes. Best for traders who want to validate the end-to-end connection before adding complexity.
Template 2: Alert-to-Order with Google Sheets Logging
The complete workflow from this tutorial — Webhook → token check → market hours check → OpenAlgo → Google Sheets → Telegram. All node mappings pre-configured with placeholders for your credentials. Includes error-path logging to a second Sheets tab labelled "Errors".
Template 3: Semi-Automated with Telegram Approval Button
Webhook → token check → market hours check → Telegram (with Approve/Reject inline keyboard) → Wait for webhook resume → OpenAlgo → Sheets → confirmation Telegram. The Wait node timeout is pre-set to 60 seconds — if you don't approve within a minute, the signal is automatically logged as "Expired — no approval" and the workflow ends cleanly.
To import any template into n8n: go to Workflows → Import from file, select the JSON file, then add your credentials. Each template includes inline sticky notes explaining every node configuration.
[Subscribe or join the community to access the templates pack.]
Comment Below
What's the manual trading step you most want to automate — and what's stopping you from automating it right now? Is it technical (don't know how to set up the webhook or configure the API)? Trust-related (scared to let an algo trade while you're not watching)? Or regulatory (not sure if automated retail trading is permitted for your account type under current SEBI guidelines)?
Be specific — I'm building a FAQ directly from your answers. If five people say they're stuck on the same step, that step gets its own detailed post with screenshots.
Keep Learning
The order layer — OpenAlgo Webhooks + TradingView: Fire Real Broker Orders From Alerts → Read the guide
The signal layer — Pine Script v6 Alerts → OpenAlgo: The Complete Tutorial → Read the guide
Add code when you're ready — Backtest NSE Futures Momentum in 50 Lines with vectorbt → Read the guide
FAQ
Q: Does n8n support Indian brokers directly, or do I still need OpenAlgo?
n8n does not have native integrations for Indian brokers like Zerodha, Fyers, Angel One, or Shoonya. n8n is a general-purpose workflow builder — it can make HTTP requests to any API, but it has no built-in understanding of broker-specific authentication flows or order formats. OpenAlgo is the translation layer: it normalises your order payload and handles the broker-specific API authentication, giving you one consistent API to call regardless of which broker you use. n8n talks to OpenAlgo; OpenAlgo talks to your broker. That separation is the architecture.
Q: What happens if my n8n server goes down in the middle of market hours?
On n8n Cloud, the platform handles uptime. On self-hosted, you need a process manager (Docker with --restart always handles this) and ideally an uptime monitor that alerts you if the server is unreachable. If n8n is down when TradingView fires an alert, the webhook request will fail silently — TradingView does not retry webhook failures. This means missed signals. Options: use n8n Cloud for the webhook receiver; set up a lightweight VPS with monitoring; or accept that self-hosted carries this operational risk and size your positions accordingly.
Q: Is this legal under SEBI's algorithmic trading rules for retail traders?
This post is educational and does not constitute legal or regulatory advice. As of early 2026, SEBI's framework for algorithmic trading is actively evolving — the 2024 consultation paper and subsequent circulars have introduced new requirements around algo approval, risk controls, and broker-side validation for retail algo orders. You are responsible for understanding and complying with the regulations applicable to your account type, broker, and order flow. Speak to your broker's compliance team before going live with any automated order flow. Some brokers have specific API usage agreements that govern automated execution.
Q: How do I handle OpenAlgo returning an error response — will n8n know the order failed?
By default, n8n treats any HTTP response that is not a 2xx status code as an error and will route the workflow to the error branch. However, OpenAlgo may return a 200 OK with a body that contains "status": "error" — a "successful" HTTP call that represents a failed order. To handle this correctly, add an IF node after the HTTP Request node that checks {{ $json.status === 'success' }}. Route the true branch to your Sheets log and success Telegram. Route the false branch to your error Sheets tab and failure Telegram. This IF node is what turns a silent failure into a visible alert.
Q: Can I use this same n8n workflow for multiple strategies and symbols?
Yes, and it's one of the strongest arguments for this architecture. Because the n8n workflow reads all order parameters dynamically from the incoming webhook payload ({{ $json.symbol }}, {{ $json.action }}, {{ $json.quantity }}), the same workflow handles any symbol and any action as long as the payload includes the correct fields. You can run 10 different TradingView strategies, all pointing at the same n8n webhook URL, and a single workflow handles all of them. The Google Sheets log automatically captures which strategy fired each signal via the Strategy column. The only constraint is that all strategies must use the same payload structure — standardise your TradingView alert message template across all strategies and you are done.
Do This Next
- Decide: n8n Cloud or self-hosted? If self-hosted, provision a VPS and run the Docker one-liner from Step 1 before proceeding.
- Create a new n8n workflow and add the Webhook node. Send a test POST request using curl or Postman and confirm you can see the parsed JSON in the output panel.
- Add the token validation IF node immediately after the webhook. Set your secret token. Confirm that a request without the correct token is rejected.
- Enable paper trading mode in OpenAlgo. Add the HTTP Request node and send one test order. Confirm it appears in the OpenAlgo paper trade log.
- Create your Google Sheets trade log with the column headers from Step 4. Connect the Google Sheets node and confirm a test row is appended correctly.
- Set up your Telegram bot via BotFather. Add the Telegram node. Confirm you receive a test message on your phone.
- Add the market hours IF node and verify the IST time logic works correctly — test it with a manual execution at a time outside 9:15 AM–3:30 PM IST.
- Run the full workflow end-to-end in paper trading mode for a minimum of 10 trading sessions before considering any live account connection.
Be the first to comment