MarketInOut Stock Screener Log In | Sign Up

How to Backtest a Stock Screening Strategy, Step by Step

By MarketInOut · November 15, 2026

A screen tells you which stocks match your rules today. A backtest tells you what would have happened if you had bought every match in the past and sold it by your exit rules. It’s the quickest way to find out whether an idea is worth your money before you risk any. Here’s how to set one up in MarketInOut’s strategy backtester, step by step, and how to read the results.

Step 1: Write the entry rule

Open the Strategy Backtest page, name the strategy and choose Long or Short. Then set the criteria for opening a position, in one of three ways:

  • Type a formula, the same as in the formula screener.
  • Extract the criteria from a saved screen, so you test exactly what you screen for.
  • Pick criteria from the selection dialog.

For example, buy S&P 500 members when the price crosses above its 200-day average:

index(sp500) and price ca sma(200)

If you’d rather not write formulas, describe the idea to the AI screener, then copy the formula it writes into the backtester.

Step 2: Choose the stocks to test on

The backtester has no separate field for the stock list: the universe is part of the entry formula, just as in the screener. Some options:

index(sp500) and ...                  /* S&P 500 members */
exch(tsx) and type(stock) and ...     /* stocks on the TSX */
ticker(aapl, meta, msft) and ...      /* a few tickers */
[my long ideas] and ...               /* a watchlist or portfolio, by name */

For a long list, create a watchlist and put its name in square brackets. If a saved screen runs on a watchlist, extracting the criteria from it brings the watchlist along. Forex and crypto strategies have their own Crypto Backtest tool.

Step 3: Decide how positions close

A position can close in three ways, and you can combine them:

  • A closing formula, checked on each bar, for example price cb sma(200) to sell when the price crosses back below its 200-day average. The universe isn’t needed here.
  • Stops and targets: stop loss, take profit and trailing stop, in percent or in multiples of ATR.
  • Time limits: close after a set number of bars, or at the end of every day, week, month, quarter, half-year or year.

How stops behave in a backtest is not obvious; our guide to stop loss, take profit and trailing stops explains it with examples.

Step 4: Set the money rules

  • Initial capital and capital at risk per trade, as a fixed amount or a percentage of capital.
  • Portfolio max size: how many positions can be open at once.
  • Prioritize stocks by: which matches to buy first when there are more matches than free slots. Always set it; without it, the order is close to alphabetical.
  • Commission and bid-ask spread. Fast strategies with many trades can look great before costs and poor after them.
  • Testing period and benchmark, such as the S&P 500, to compare your results with.

How capital, portfolio size and position size work together is explained in how the backtester simulates trades.

Step 5: Run it and read the results

Click Backtest. The strategy is saved automatically, and the results page opens when the test finishes, which can take a few minutes. Look at these first:

  • Annual return against the benchmark, year by year. A strategy that beats the index in one year and trails it in every other isn’t a strategy.
  • Maximum drawdown: the largest fall in the equity curve from a peak, for example from $200,000 to $150,000, a 25% drawdown. Ask yourself whether you could have sat through it.
  • Number of trades and the share of winners. A handful of trades proves little.
  • Profit factor: gross profit divided by gross loss. Above 1 means the winners paid for the losers.
  • Market impact: how big each position was against the stock’s average daily volume. “Huge” means a real portfolio couldn’t have traded that size.
  • The trade list. Check a few trades on a chart. “Period End” means a position was still open when the test ended, or the stock stopped trading.

Delisted stocks stay in the data, and prices, fundamentals and index membership are stored as of each date, so the test can only buy what was really there at the time.

If the backtest is slow

Test time grows with the size of the universe, the length of the period and the complexity of the entry rule. Start with a shorter period or a smaller universe, such as one index, and widen it once the strategy looks promising.

Common mistakes

  • Testing only the good years. Include at least one bear market.
  • Leaving out costs. Set a realistic commission and spread from the start.
  • Tuning until it looks perfect. The more settings you tweak to fit the past, the less the result says about the future. Check that the strategy still works with slightly different numbers.

FAQ

Can I backtest for free?

The free version and the 7-day free trial run backtests on the current year, and the free version can’t save them. A Pro membership tests the full history, which goes back to 2000.

Can one strategy go long and short?

No. Long and short positions can’t be combined in one strategy. Create two strategies, one long and one short.

Where can I read more?

The help pages cover setting up a strategy and backtesting a custom list of stocks.




Disclaimer - Privacy Policy - Terms of Service - Cookies - FAQ - Affiliates - Blog