A fully automated NSE Breakout + Momentum Swing Trading Bot with:
- 🔍 5 pattern detectors (VCP, Bull Flag, 52W High, Ascending Triangle, Double Bottom)
- 📊 100-point momentum scoring (EMA stack, RSI, ADX, Volume, ATR compression)
- 🛡️ ATR-based SL/T1/T2 with automatic trailing stop
- 📱 Telegram alerts for every signal, entry, and exit
- 🌐 Live dashboard at
http://localhost:8888 - 🧪 Walk-forward backtester with full performance stats
- 📈 NSE Options OI filter (PCR, Max Pain, Delta/Gamma)
# 1. Clone the repo
git clone https://github.com/YOUR_USERNAME/nse-swing-bot.git
cd nse-swing-bot
# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure (edit config.py)
# - Set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID (optional)
# - Adjust CAPITAL, risk params, universe as needed
# 5. Run the bot
python3 trading_bot.pyOpen http://localhost:8888 for the live dashboard.
nse-swing-bot/
├── trading_bot.py # Main bot: scanner + positions + alerts + server
├── backtester.py # Walk-forward historical backtest engine
├── options_filter.py # NSE option chain: PCR, Max Pain, greeks
├── config.py # All configuration in one place
├── dashboard.html # Live dark-themed dashboard (6 tabs)
├── requirements.txt
├── .gitignore
└── bot_data/ # Auto-created: logs, JSON state, dashboard data
├── bot.log
├── positions.json
├── signals.json
├── trades.json
├── dashboard.json
├── backtest_results.json
└── options_data.json
| Parameter | Default | Description |
|---|---|---|
CAPITAL |
₹5,00,000 | Virtual paper capital |
RISK_PER_TRADE |
1% | Risk per trade (position sizing) |
MAX_POSITIONS |
10 | Max concurrent open positions |
MIN_SCORE |
65 | Minimum momentum score to enter |
MIN_RSI / MAX_RSI |
50 / 78 | RSI filter range |
MIN_ADX |
20 | Minimum trend strength |
ATR_SL_MULT |
1.5× | Stop-loss = entry − 1.5×ATR |
ATR_T1_MULT |
2.5× | Target 1 = entry + 2.5×ATR |
ATR_T2_MULT |
4.0× | Target 2 = entry + 4×ATR |
TRAIL_TRIGGER |
5% | Start trailing after +5% gain |
TRAIL_FACTOR |
60% | Trail at 60% of move from entry |
- Create a bot via @BotFather → get
BOT_TOKEN - Get your chat ID via @userinfobot
- In
config.py:TELEGRAM_ENABLED = True TELEGRAM_BOT_TOKEN = "7123456789:AAF..." TELEGRAM_CHAT_ID = "123456789"
python3 backtester.py # 1-year backtest on full universe
python3 backtester.py --period 2y # extend to 2 years
python3 backtester.py --sym RELIANCE # single stockResults are saved to bot_data/backtest_results.json and shown in the dashboard's Backtest tab.
python3 options_filter.py # NIFTY option chain
python3 options_filter.py --sym BANKNIFTYFetches live NSE data (no login), computes PCR, Max Pain, OI buildup and ATM greeks (Delta, Gamma, Theta, Vega). Enable the filter in config.py with OPTIONS_ENABLED = True.
| Time (IST) | Action |
|---|---|
| 09:20 | Morning scan — detect signals, enter positions |
| 15:25 | EOD check — update prices, check exits, Telegram summary |
This is a paper trading simulation for educational purposes only. No real orders are placed. Past backtested performance does not guarantee future results. Always do your own research before investing real capital.
MIT License — free to use, modify, and distribute.