Live · Upstox v3 · n8n + Lovable frontend

Opening Range Breakouts.
Filtered, scored, executed.

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.

Every-minute polling 📊 Upstox v3 REST API 🎯 4-filter conviction gating 🇮🇳 NSE intraday only

The strategy in one paragraph.

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.

How it works.

Triggered by editing a single cell in a Google Sheet. Everything downstream is automated.

  1. Toggle a Sheet cell

    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.

  2. Pass instrument key + symbol

    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.

  3. Fetch candles + last price (parallel)

    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.

  4. Calculate the technical filters

    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.

  5. Score the breakout

    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.

  6. Place the order

    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.

The four filters that gate every trade.

A breakout candle isn't enough. All four below must align — and the opening range itself must have been tight enough to count.

📐

Opening range

first 5 candles

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.

🤏

BB squeeze

width < 0.02

Mean Bollinger Band width across the opening range must be below 2% — confirms the range was actually tight, not just a coincidental high/low.

📈

ADX

> 25

Average Directional Index above 25 means the market is trending, not chopping. Without this, ORB signals become coin-flips.

⚖️

RSI

30 < RSI < 70

Relative Strength Index in the middle band — not already overbought or oversold. Avoids buying tops and shorting bottoms.

📊

Volume

> 14-period avg

The breakout candle's volume must exceed the trailing 14-period average. Low-volume breakouts are the most reliable fakeouts.

🎯

Direction

LONG / SHORT

Close above opening-range high → LONG. Close below opening-range low → SHORT. Equal closes are skipped.

🛑

Stop loss

opposite range edge

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.

📝

Audit trail

Sheet log

Every check (passed or failed) is logged back to a Sheet with timestamp, filters' values, and outcome. Future you will want this.

Architecture.

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

A real signal looks like this.

Example readout from a hypothetical RELIANCE 3-minute breakout. Real format; values illustrative.

NSE:RELIANCE-EQ ▲ LONG signal
Opening range high
₹2,847.20
✓ break-above @ 09:30
BB width (range mean)
0.014
✓ < 0.02 (squeeze)
ADX(14)
31.4
✓ > 25 (trending)
RSI(14)
58.2
✓ in 30–70 band
Breakout volume
182,400
✓ > 14p avg (124,700)
Stop loss
₹2,832.60
opposite range edge
Entry triggered at 09:30:00 IST. Conviction gate passed all 5 filters. Order placed via Upstox v3 /order/place for configured position size.

Built with.

Indian markets only. Upstox handles execution; everything else is n8n.

n8n Upstox v3 REST API Google Sheets Trigger technicalindicators (npm) JavaScript Code nodes Lovable (frontend)

⚠️ Read this before you wire it to a live broker.

Trading involves risk. This is engineering content, not financial advice.

⚠️ Disclaimer

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.

Fork it.

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.