---
title: "rule_backtest: Test a trading rule on history — eqdoc MCP tool"
description: "Test your own rule on daily prices: trades, win rate, return against holding and the Nifty 50, drawdown, by year. Past only; costs not modelled."
url: "https://eqdoc.com/mcp/tools/rule_backtest"
---

# rule_backtest: Test a trading rule on history

Test your own rule on daily prices: trades, win rate, return against holding and the Nifty 50, drawdown, by year. Past only; costs not modelled.

## What it returns

The trades, win rate, average return, total return against holding and against the Nifty 50, the worst drawdown and a year-by-year split, all on past prices.

## Inputs

| Input | Required | Note |
|---|---|---|
| `symbols` | no | NSE tickers or BSE codes; delisted names work. Give exactly one of symbols, index, sector |
| `index` | no | an index by name ('NIFTY 50', 'Bank Nifty'): its largest members by market cap; up to 60 characters |
| `sector` | no | a sector or industry by name ('banks', 'pharma'): its largest members by market cap; up to 60 characters |
| `top` | no | for index or sector: how many of the largest members (default all of them, at most 50); 1..50 |
| `entry` | yes | object |
| `exit` | yes | object |
| `years` | no | look-back in years (default 5, at most 10) when from is not given; ..10 |
| `from` | no | YYYY-MM-DD, the first day of the window |
| `to` | no | YYYY-MM-DD, the last day (default the last settled close) |

## Example questions

- How would buying Nifty 50 stocks when RSI(14) is below 30 and the close is above the 200-day average, and leaving after 20 sessions, have done over five years?
- Test a 50-day and 200-day moving average crossover on the Nifty Bank members.
- What happened when IT stocks closed above their 52-week high and were held for 10 sessions?

## Related tools

- [signal_backtest](https://eqdoc.com/mcp/tools/signal_backtest): How a chart signal or pattern fared in the past, market-wide or for one company with each dated signal: win rate, returns, excess over the Nifty.
- [indicator_screen](https://eqdoc.com/mcp/tools/indicator_screen): Which companies meet one or more technical conditions across the market: RSI, ADX, MACD, averages, Supertrend, crosses in N sessions, and / or.
- [technicals](https://eqdoc.com/mcp/tools/technicals): A company's or index's technical indicators at its last close: RSI, moving averages, MACD, Bollinger Bands, support and resistance and more.
- [price_change](https://eqdoc.com/mcp/tools/price_change): How a stock or index moved over any window: start and end closes, change, highs and lows, drawdown and volatility.

## Data freshness

Prices and indicators are end of day, as of the last close. Company figures are as filed, each with its date. There are no live prices.

## More

- Part of the [Screening](https://eqdoc.com/mcp/tools#g-screening) group in the [tool reference](https://eqdoc.com/mcp/tools).
- [Set up the eqdoc MCP server](https://eqdoc.com/mcp) in Claude, ChatGPT, Cursor and other AI apps.
- [Limits and what each message means](https://eqdoc.com/mcp/docs/limits)

## Main sections

- [Home: ask the research desk](https://eqdoc.com/)
- [Stock screener](https://eqdoc.com/screener)
- [EqScore](https://eqdoc.com/eqscore)
- [Exchange filings](https://eqdoc.com/filings)
- [Results calendar](https://eqdoc.com/results-calendar)
- [Bulk and block deals](https://eqdoc.com/deals)
- [Stocks: the largest companies and A to Z](https://eqdoc.com/stocks)
- [Sectors](https://eqdoc.com/sectors)
- [Sector reading guides](https://eqdoc.com/guides)
- [Pricing](https://eqdoc.com/pricing)
- [Accuracy and verification](https://eqdoc.com/accuracy)
- [About eqdoc](https://eqdoc.com/about)
- [MCP server for AI tools](https://eqdoc.com/mcp)
- [Contact](https://eqdoc.com/contact)
