An algorithmic intraday trading agent built in n8n. Triggers on a Google Sheets toggle, fetches 3-minute candles from Upstox v3, scores breakouts with ADX + RSI + Bollinger squeeze + volume confirmation, and places orders only when conviction is high.
Opening Range Breakout (ORB) trades the first decisive move after the market opens. Bull thesis: when the first 5 candles form a tight range with a Bollinger squeeze, a breakout above the range high — confirmed by ADX trend strength, RSI in a healthy zone, and volume above average — is a high-probability long. Bear thesis: the symmetric short. The agent only fires when all four filters agree, which keeps the trade count low and the win rate honest.
Triggered by editing a single cell in a Google Sheet. Everything downstream is automated.
A Google Sheets Trigger polls every minute, watching a column called Automation Trigger. Set the value to Check Trade for any instrument row and the workflow fires for that row.
The matched row's instrument_key, Company Name, and trading_symbol are extracted and passed downstream. SplitInBatches makes the workflow safe to run on multiple rows in a single tick.
Two HTTP requests fire in parallel against Upstox v3: /market-quote/ltp for the live last-traded price, and /historical-candle/intraday/{key}/minutes/3 for the 3-minute candle series. A Merge node fans them back together.
A Code node runs the technicalindicators npm package to compute ADX(14), RSI(14), and Bollinger Bands(20, 2σ) across the candle series. The opening range is set as the high/low of the first 5 candles.
For each candle after the opening range, check: (a) Is the close above the range high (LONG) or below the range low (SHORT)? (b) Is current candle volume above the 14-period average? (c) Is ADX above 25 (trending)? (d) Is RSI between 30 and 70 (not over-extended)? (e) Was there a Bollinger squeeze in the opening range (band-width below 2% threshold)? All five must pass to qualify.
If qualified, the agent hits Upstox's order placement endpoint with a configurable position size and a stop-loss anchored to the opposite side of the opening range. The trade is logged back to the Sheet for audit.
A breakout candle isn't enough. All four below must align — and the opening range itself must have been tight enough to count.
High/low of the first 5 candles defines the range. If the first candle has >4% wick, or the open-to-close gap exceeds 4%, the whole setup is skipped.
Mean Bollinger Band width across the opening range must be below 2% — confirms the range was actually tight, not just a coincidental high/low.
Average Directional Index above 25 means the market is trending, not chopping. Without this, ORB signals become coin-flips.
Relative Strength Index in the middle band — not already overbought or oversold. Avoids buying tops and shorting bottoms.
The breakout candle's volume must exceed the trailing 14-period average. Low-volume breakouts are the most reliable fakeouts.
Close above opening-range high → LONG. Close below opening-range low → SHORT. Equal closes are skipped.
SL is set to the opposite edge of the opening range. Asymmetric R:R is the point — small loss if wrong, full breakout if right.
Every check (passed or failed) is logged back to a Sheet with timestamp, filters' values, and outcome. Future you will want this.
n8n orchestrates the whole thing. Upstox is the only external dependency (besides Google Sheets).
flowchart TD
A[📋 Sheet Trigger
every minute] --> B{Automation Trigger
== 'Check Trade'?}
B -- yes --> C[Pass Instrument Key]
B -- no --> Z[skip]
C --> D[Split In Batches]
D --> E[Last Price
Upstox /ltp]
D --> F[3-min Candles
Upstox /intraday]
E --> G[Merge]
F --> G
G --> H[Technical Analysis
ADX + RSI + BB + Volume]
H --> I{All 5 filters
pass?}
I -- yes --> J[Place Order
Upstox API]
I -- no --> K[Log skip reason
to Sheet]
J --> L[Log fill
to Sheet]
style J fill:#10b98120,stroke:#10b981,color:#fff
style A fill:#21262d,stroke:#30363d,color:#e6edf3
style B fill:#21262d,stroke:#30363d,color:#e6edf3
Example readout from a hypothetical RELIANCE 3-minute breakout. Real format; values illustrative.
09:30:00 IST. Conviction gate passed all 5 filters. Order placed via Upstox v3 /order/place for configured position size.
Indian markets only. Upstox handles execution; everything else is n8n.
Trading involves risk. This is engineering content, not financial advice.
This workflow is published as engineering content. It is not financial advice, not a trading recommendation, and not a guarantee of returns. Past backtest behavior does not predict future results.
Before connecting to a live Upstox account: paper-trade for at least 2-4 weeks; verify every filter threshold against your own market understanding; set position sizes you can afford to lose; understand Indian SEBI rules around algo trading. The author takes no responsibility for losses incurred by using this workflow.
Always paper-trade first. Always.
Workflow JSON is in the repo. Wire Upstox credentials, set up your Sheet with the right columns, paper-trade until you're satisfied. Then — only then — connect live.