Skip to content
TradeBridge

Trading

Backtest a rule on past prices

Describe a trading rule in your own words or build it step by step, then see how it would have behaved on past daily candles.

Backtest (in the main menu) shows how a rule would have behaved on past daily prices. It is a record of the past, not a prediction or advice, and it never places orders.

1. Describe the rule, or build it

  • In your own words: for example "Buy SBIN when it closes above its 20-day high, sell when it closes below the 50-day average, stop-loss 5%, 2022 to 2025". Press Turn into rules. The AI only translates what you wrote and lists any assumption it had to make, for example "RSI period 14, as none was given". Check the rules and change them if needed. Descriptions it can't test, such as intraday timing, news or fundamentals, or requests for advice, are refused with the reason.
  • Step by step: build the rules yourself. You don't need the AI.
Rule part What you can use
Entry (all must be true) Up to 5 conditions
Exit (any one is enough) Up to 5 conditions
Each condition Price (open, high, low, close), SMA, EMA, RSI, highest high or lowest low of the previous N days, volume, average volume, or a fixed number. Compare with is above, is below, crosses above or crosses below.
Optional Stop-loss %, target %, maximum days in a trade

2. Choose the prices

  • From my broker: past daily candles from your own logged-in Zerodha, Dhan or Upstox account. They are used for you only and not stored.
  • Upload a CSV: a file with date (or time), open, high, low, close and, optionally, volume columns, for example exported from TradingView. Dates may be YYYY-MM-DD, DD-MM-YYYY, DD/MM/YYYY or a timestamp. The file is used for that run only.

At least 30 daily candles are needed between the dates you pick.

3. Read the results

You get total return, buy-and-hold over the same period for comparison, the largest drawdown, the number of trades, win rate, average win and loss, profit factor, an equity chart and every trade with why it closed.

How trades are simulated:

  • A rule is checked at each day's close, and the trade happens at the next day's open. So the test never uses a price it couldn't have known at the time.
  • A stop-loss or target fills at its level. If the price gapped past it, it fills at that day's open. If both could have filled on the same day, the stop-loss is assumed.
  • One trade at a time, using the whole account value in whole shares.
  • The costs per side you enter (charges plus slippage, as a % of the traded value) are deducted on every buy and sell.

Real results differ: prices move during the day, orders can fill worse than the open, and the past doesn't repeat.

Run the rules live on Paper

Below the results, Run these rules live on Paper starts the same rules on your Paper accounts. Choose the accounts, the quantity per account (a multiple of the lot size), the product, and a candle length: 1, 3, 5, 15, 30 or 60 minutes.

  • The engine builds candles from your price feed: your own broker's live price when it streams, otherwise the simulated market. Candles line up with clock times in IST (09:15, 09:20 and so on for 5-minute candles).
  • At each candle's close it checks the rules. It exits first (exit rule, target, or the maximum candles in a trade), then enters if you have no position. Each order goes through the usual checks: kill switch, risk limits, trading guardrails and approvals. To ask before each order, tick Live strategies under Ask me before placing large automated orders.
  • A stop-loss % is placed as a protective stop as soon as the entry fills.
  • Indicators need enough candles first. A 50-candle average acts only after 50 candles. After an engine restart, counting starts again.
  • Pause, Resume and Stop are under Live strategies. Pausing or stopping never closes an open position; exit it from the terminal if you want to.

Real broker accounts can't run live strategies here: brokers don't allow third-party algo platforms to place orders through their APIs.

Last updated