Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IntradayBot Banner

IntradayBot

Algorithmic Intraday Trading System for NSE (India)
Regime-Filtered Signal Engine with Live Market Data, Risk Management & Real-Time Dashboard

Live Demo Next.js TypeScript Tailwind shadcn/ui Yahoo Finance

Live: regime-trading-engine.space-z.ai


Overview

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.


Key Features

Regime Engine (6 Market Quality States)

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

5 Hard Regime Filters

  1. TIME_SESSION — Blocks off-hours, opening range, and lunch sessions
  2. ADX_TREND — ADX must be >= 20 (rejects sideways markets)
  3. ATR_EXPANSION — ATR/Price must be >= 0.3% (rejects dead stocks)
  4. CANDLE_BODY — At least 2 of last 3 candles must have body >= 40% of range
  5. 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.

Signal Engine (6 Conditions)

BUY Conditions:

  1. Price > EMA9
  2. EMA9 > EMA20 (bullish alignment)
  3. RSI > 48 (trade) / 45 (signal display)
  4. ADX > 20 (trade) / 12 (signal display)
  5. +DI > -DI (bullish directional)
  6. 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.

Risk Management

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

13 Exit Conditions (3 Urgency Levels)

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

Architecture

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)

Tech Stack

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

Getting Started

Prerequisites

  • Bun (recommended) or Node.js 18+
  • No API keys required — Yahoo Finance is used without authentication

Installation

# 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 dev

Open http://localhost:3000 in your browser.

Environment Variables

Create a .env file in the root directory:

DATABASE_URL="file:./db/custom.db"

That's it — no API keys or external services required.


Usage

  1. Configure — Set your capital, risk %, watchlist, and square-off time in the Configuration panel
  2. Start — Click the "Start Bot" button to begin scanning
  3. Monitor — Watch live signals, active trades, and regime state in real-time
  4. Review — Check rejected trades (the "Rejections" tab shows exactly WHY trades were blocked)

Key Design Decisions

  1. Regime is Authoritative — If regime fails, strategy NEVER runs. It's a hard block, not "reduced confidence."
  2. Trade Rejection Logging — Every rejected trade is logged with reason, regime state, and blocking filter.
  3. Auto-Close on IMMEDIATE Urgency — Stop losses, trailing stops, and targets are auto-executed.
  4. Opening Range Breakout (ORB) — The 9:15-9:30 IST range is built automatically; only breakout trades are taken after 9:30.
  5. Lunch Session Kill Switch — No new trades between 12:00-13:30 IST.
  6. Dual Threshold System — Relaxed thresholds for signal display, stricter thresholds for trade execution.

Technical Indicators

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

Disclaimer

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.


License

MIT

Author

Sarthak Arya · github.com/sarthak070707 · sarthakarya4@gmail.com

About

Full-stack intraday trading simulation platform with regime-based market filtering, modular execution architecture, real-time signal analysis, and risk-managed paper trading.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages