Algorithmic Intraday Trading System for NSE (India)
Regime-Filtered Signal Engine with Live Market Data, Risk Management & Real-Time Dashboard
Live: regime-trading-engine.space-z.ai
IntradayBot is a fully self-contained intraday trading system for the National Stock Exchange of India (NSE). It combines a 6-state Regime Engine that classifies market quality in real-time, a Signal Engine that generates entry/exit signals from 6 technical conditions, and a Risk Engine that manages position sizing, stop-losses, and daily limits — all presented through a real-time Next.js dashboard.
Note: This is a signal generation & tracking system. It does not execute real orders on any exchange.
The Regime Engine is the authoritative gatekeeper — if the regime doesn't pass, no trade is generated.
| State | Meaning | Tradeable? | Trigger |
|---|---|---|---|
| TRENDING | All filters pass, clear directional move | Yes | Quality score >= 70 |
| CHOPPY | ADX too low, sideways/indecision | No | ADX < 20 or weak candles |
| LOW_VOLATILITY | ATR too low, dead stock | No | ATR/Price < 0.3% |
| OPENING_VOLATILITY | Before 9:30 IST, chaotic open | No | Session is OPENING_RANGE |
| LUNCH_SESSION | 12:00-13:30 IST, momentum dies | No | Session is LUNCH |
| OVEREXTENDED | Price too far from VWAP, chasing | No | Price > +/-1.5% from VWAP |
- TIME_SESSION — Blocks off-hours, opening range, and lunch sessions
- ADX_TREND — ADX must be >= 20 (rejects sideways markets)
- ATR_EXPANSION — ATR/Price must be >= 0.3% (rejects dead stocks)
- CANDLE_BODY — At least 2 of last 3 candles must have body >= 40% of range
- VWAP_DISTANCE — Price must be within +/-1.5% of VWAP (rejects chasing)
Plus an Opening Range Breakout (ORB) check: trades inside the 9:15-9:30 IST range are blocked.
BUY Conditions:
- Price > EMA9
- EMA9 > EMA20 (bullish alignment)
- RSI > 48 (trade) / 45 (signal display)
- ADX > 20 (trade) / 12 (signal display)
- +DI > -DI (bullish directional)
- Volume spike (> 1.1x average)
SELL Conditions: Mirror of BUY.
| Strength | Condition |
|---|---|
| STRONG | 6/6 + RSI in sweet spot |
| MODERATE | 5/6 conditions |
| WEAK | 3-4/6 conditions |
Trade execution requires 4/6 conditions + 3 core conditions + regime must be TRENDING.
| Rule | Value |
|---|---|
| Risk per trade | 1% of capital |
| Daily loss limit | 3% of capital (hard block) |
| Max open trades | 5 |
| Trade cooldown | 5 min per stock |
| Square-off time | 15:15 IST (auto-close all) |
| Trailing stop | 1% trail, only moves favorably |
| One trade per stock | No duplicate positions |
| Urgency | Auto-Action | Examples |
|---|---|---|
| IMMEDIATE | Auto-closed | Stop loss, Target hit, Trailing stop, Extreme RSI |
| WARNING | Alert only | RSI overbought, EMA crossover, Market close approaching |
| WATCH | Monitor | ADX weakening, Volume drying, Breakeven stop |
Market Data -> Indicators -> Regime Engine -> Signal Engine -> Execution Engine
(Yahoo API) (EMA/RSI/ (5 filters + (6 conditions) (8 checks +
ADX/ATR/ ORB + score) rejection log)
VWAP/Vol)
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router, React 19, Turbopack) |
| Language | TypeScript 5 (strict) |
| Styling | Tailwind CSS 4 + shadcn/ui (New York) |
| State | Zustand 5 (client), TanStack Query 5 (server) |
| Database | SQLite via Prisma 6 |
| Charts | Recharts 2.15 |
| Market Data | Yahoo Finance v8/v7 API (no API key needed) |
| Runtime | Bun |
| Icons | Lucide React |
- Bun (recommended) or Node.js 18+
- No API keys required — Yahoo Finance is used without authentication
# Clone the repository
git clone https://github.com/sarthak070707/Regime-trading-engine.git
cd Regime-trading-engine
# Install dependencies
bun install
# Set up the database
bun run db:push
# Start the development server
bun run devOpen http://localhost:3000 in your browser.
Create a .env file in the root directory:
DATABASE_URL="file:./db/custom.db"That's it — no API keys or external services required.
- Configure — Set your capital, risk %, watchlist, and square-off time in the Configuration panel
- Start — Click the "Start Bot" button to begin scanning
- Monitor — Watch live signals, active trades, and regime state in real-time
- Review — Check rejected trades (the "Rejections" tab shows exactly WHY trades were blocked)
- Regime is Authoritative — If regime fails, strategy NEVER runs. It's a hard block, not "reduced confidence."
- Trade Rejection Logging — Every rejected trade is logged with reason, regime state, and blocking filter.
- Auto-Close on IMMEDIATE Urgency — Stop losses, trailing stops, and targets are auto-executed.
- Opening Range Breakout (ORB) — The 9:15-9:30 IST range is built automatically; only breakout trades are taken after 9:30.
- Lunch Session Kill Switch — No new trades between 12:00-13:30 IST.
- Dual Threshold System — Relaxed thresholds for signal display, stricter thresholds for trade execution.
| Indicator | Period | Purpose |
|---|---|---|
| EMA | 9 & 20 | Trend direction & crossover signals |
| RSI | 14 | Momentum / overbought-oversold |
| ADX / DMI | 14 | Trend strength & directional bias |
| ATR | 14 | Volatility & stop-loss calculation |
| VWAP | — | Intraday institutional benchmark |
| Volume Spike | 20-period avg | > 1.1x average volume detection |
This project is for educational and research purposes only. It does not constitute financial advice and should not be used for actual trading without proper risk assessment. Signals are based on technical indicators and are not guaranteed to be profitable. Always do your own research and consult a qualified financial advisor before making any investment decisions.
MIT
Sarthak Arya · github.com/sarthak070707 · sarthakarya4@gmail.com
