AI-Powered NSE Stock Strategy Backtester
1. Inputs
How it works
- Pick a symbol, dates, capital, and timeframe (daily or weekly).
- Describe your strategy in plain English in the right panel — including any stop-loss / target / trailing stop.
- Click Build AI Strategy — the LLM converts your words into a structured spec.
- Review the preview — indicators, entry/exit rules, the SQL fetch.
- Click Run Backtest. Trades execute at the next bar's open. You'll get metrics, 7 charts, a monthly returns heatmap, a trade log, and an Excel download.
📊 Supported indicators (27)
Trend & moving averages — SMA, EMA, MACD (line / signal / histogram), Bollinger Bands (upper / middle / lower), Supertrend (line + direction).
Momentum oscillators — RSI, Stochastic %K & %D, Williams %R, ROC, TRIX, MFI, CCI.
Trend strength & direction — ADX, +DI, -DI, Aroon Up, Aroon Down.
Volatility — ATR, Bollinger Bands.
Breakout — rolling N-bar high / low (Donchian-style).
Volume — OBV.
🛡️ Stop-loss, targets & trailing stops
Just say it in the strategy: "…with a 5% stop loss", "book profits at 20%", "trail a 10% stop below the high".
Protective exits are checked intrabar on every bar in position — a gap through the level fills at the open, and if a stop and target could both hit on the same bar, the stop wins (pessimistic).
Each trade in the log shows why it exited: signal, stop-loss, take-profit, or trailing stop.
🔧 How conditions work
Compare values with > < >= <= == or use crossover_above / crossover_below for true crossings.
Each side can be: an indicator name, a price field (open/high/low/close/volume), or a number.
Up to 4 conditions per side, joined by AND.
Stop-order triggers work too: "buy next week above the previous 13-week high" fills only if the next bar actually crosses that price.
⚙️ Execution model
Long-only, one position at a time. All-in capital allocation.
Daily or weekly bars; orders fill at the next bar's open (no look-ahead), or at the trigger price for stop-order entries.
0.1% per-side fee assumed. Universe: 4,800+ NSE & BSE equities, with data available from 2004-01-01.
🚫 What's not supported
Indices/options/futures, intraday timeframes, short selling, absolute-price stops ("stop at ₹950"), leverage, multi-ticker portfolios, fundamentals (P/E, EPS), and OR-logic between conditions.
2. Strategy (natural language)
3. Preview will appear here
Click Build AI Strategy, and the parsed strategy (indicators, entry/exit rules, SQL) will show up here.
Then click Run Backtest to render results below.
Results will appear here
Pick a symbol, write a strategy, parse it, then run the backtest. You'll get headline metrics, six charts, a monthly returns heatmap, and a trade log — plus an Excel download.
Popular strategies you can test
- 200-day SMA crossover — a classic long-term trend follower: buy when price closes above the 200-day moving average; sell when it closes below.
- RSI mean reversion — buy when 14-day RSI drops below 30 (oversold) and exit when RSI rises above 70 (overbought).
- MACD signal-line crossover — go long when the MACD line crosses above its signal line (12/26/9 default).
- Bollinger band reversion — buy when price touches the lower 20-day Bollinger band; exit when it returns to the middle band.
- Donchian breakout — buy when close makes a new 50-day high; exit on a 20-day low.
- Stochastic + ADX — buy on stochastic oversold reversal only when ADX confirms a strong trend.
Frequently asked questions
Is this financial advice?
No. This tool is for educational and research purposes only. Backtest results are based on historical data and simulated execution; they do not predict future performance and are not investment advice.
What data is used?
End-of-day OHLCV (open, high, low, close, volume) for 4,800+ NSE- and BSE-listed equities. Data is pulled from our existing Cloud SQL stock_prices table, which is refreshed daily by the same pipeline that powers the Flash Finance Technicals page.
How accurate are the simulated trades?
Trades fill at the next bar's open after a signal — there is no look-ahead. A flat 0.1% per-side fee is applied to approximate brokerage and slippage. Real-world results will differ due to actual slippage, taxes, partial fills, and corporate actions.
Does it support stop-losses and profit targets?
Yes. Say it in plain English — "with a 5% stop loss", "book profits at 20%", "trail a 10% stop" — and the engine checks the levels intrabar on every bar in position. The trade log shows whether each exit came from the rule, the stop-loss, the take-profit, or the trailing stop.
Can I backtest on weekly candles?
Yes — switch the timeframe to Weekly (or just say "on the weekly chart"). Daily bars are resampled into Friday-anchored weekly candles before indicators are computed, so periods count weeks (SMA 13 = 13-week SMA).
Why is short selling not supported?
The current engine is intentionally long-only with a single open position at a time. Adding shorts requires changes to position state and P&L math; it's a planned enhancement.
Can I save or share a strategy?
For now you can copy the parsed JSON spec from the Preview panel. Saved strategies and shareable links are on our roadmap.
Does it support intraday or options strategies?
Not at the moment — the underlying data is daily bars on cash equities only. Intraday data and derivatives are not in scope today.