Strategy research
How to backtest a trading strategy
Summary
A backtest applies your trading rules to historical prices. Specify what would trigger a trade, when it could fill, and how much the strategy would hold. Then check an actual simulated entry and exit before comparing returns on dates you set aside.

You have an idea: buy when a market starts trending, sell when that trend weakens, and avoid making decisions in the heat of the moment. Before putting money behind it, you need to see what those rules actually do.
Backtesting applies a defined strategy to historical data. It helps you examine the trades, losses, and periods of inactivity your rules would have produced under the test's assumptions. The useful result is a clearer understanding of your strategy, including reasons to change or abandon it.
This guide walks through a first test in Alphavator and the decisions that make the result meaningful.
Start with a question you can test
“Can I make money with moving averages?” is too broad. A more useful question is: “How would a simple trend rule have behaved on this asset, over this period, with this position size?”
For an educational example, imagine a strategy with these rules:
- Use daily closing prices for one supported asset.
- When you hold no position, buy if the completed daily close is above its 50-day simple moving average.
- Use 10% of available simulated cash for the entry, with no additional buying while that position is open.
- Sell the entire position when the completed daily close is below the same moving average.
- At equality, take no action. Keep unallocated money in cash.
These are hypothetical research rules, not a recommended investment or a claim of profitability. Their value as a first exercise is that you can explain every decision.
Notice the details: a daily close, a specific indicator length, a position size, and an exit. “Buy when the chart looks strong” leaves all four unresolved.

Build the rules in Alphavator
Open Alphavator and create a new TBOT, the platform's name for an automated trading strategy. Use the visual builder to express your conditions, or ask the AI to draft the supported rules from your written specification.
Review the generated blocks before testing. Check the symbol, timeframe, price field, indicator length, comparison direction, and order size. Read the buy and sell conditions separately, then explain how they interact.
A condition that stays true for several days is different from a condition that becomes true only on a crossover. Confirm how your TBOT handles repeated signals and existing holdings. A strategy can use familiar indicators and still trade differently from what you intended.
Choose the test settings deliberately
Open the TBOT's backtesting workflow and review the available settings. Record the date range, starting capital, and strategy version. If the rules change, give the new version a distinguishable name so you can compare the right results later.
Choose a period that gives the strategy a chance to encounter different conditions. A trend strategy tested only during a strong advance has answered a narrow question. Check whether the selected asset existed throughout the period and whether enough observations are available for the indicators.
A 50-day moving average needs historical observations before it can produce a meaningful value. Verify how the test handles this warm-up and when trading actually begins.
Check the assumptions behind each trade

A backtest needs rules for converting a signal into a simulated fill. If a condition uses the completed closing price, that price becomes known at the close. A fill at that identical close can be an optimistic assumption compared with an order submitted afterward.
Check the engine's documented timing. If your chosen test cannot model the execution you intend, record the difference instead of treating the result as an exact rehearsal.
Also examine:
- Costs: What commissions, fees, spreads, or slippage are included?
- Price data: How are splits, dividends, and missing observations handled?
- Orders: What happens when a signal cannot be filled as intended?
- Cash: Does the simulation assume a return on unused cash?
Do not assume a setting exists simply because it matters. Check what Alphavator supports for your test and document any simplifications. The SEC's guide to performance claims explains why expenses and calculation methods matter when evaluating results.
Inspect the trades before judging the return
Run the backtest, then open individual trades. Find an entry and verify that the condition was satisfied. Examine an exit. Check a long period without trades and a period with several losses.
If those decisions do not match your rules, investigate before changing parameters. A better-looking return cannot fix an incorrect implementation.
Next, review the equity curve, drawdown, trade count, and any available benchmark. Compare similar dates, capital assumptions, and costs. A strategy that holds cash most of the time has a different exposure profile from an investment that stays fully invested.
Keep a separate period for evaluation
Choose an earlier period for developing the rules and reserve a later period for evaluation. Freeze the rules before examining that later result. If you revise the strategy after seeing it, that period has become part of development.
This separation helps you ask whether the idea survives new observations, but it does not prove that the strategy will work. Research by Bailey and colleagues shows how selecting the best result from many backtests can produce misleading confidence.
Keep a simple research log: what you changed, why you changed it, and which periods you examined. Test a small number of reasoned variations rather than endlessly searching for the highest return.

Step-by-step walkthrough
The recording follows a daily QQQ breakout. Its buy rule uses a 200-day average and an upper Bollinger Band, and the simulation fills at the close. Follow its January entry through its April sale, then change the test dates while keeping the rules fixed.
Jump to a step
Step 1
Describe a trade you expect to see
In Alphavator, a TBOT is a trading robot that holds your strategy rules. In My TBOTs, open a saved Technical TBOT, select Options, then Run Backtest. If you are building one for the first time, select Create in the builder to save the rules.
The example trades QQQ, an exchange-traded fund. It buys when the daily close is above both its 200-day average and its upper Bollinger Band. It sells when the close falls below either the middle band or the 200-day average. To build the example, use daily closes and set the Bollinger Bands to a 50-day simple moving average with a multiplier of 2.1. Set QQQ’s target weight to 100% on entry and 0% on either exit. Now predict one decision. If QQQ opens the day with your bot in cash and finishes above its 200-day average but below its upper band, should the bot buy? The second condition keeps it in cash.
Step 2
Set up a run you can reproduce
In the Backtest panel, set Start Date to January 2, 2024 and End Date to October 30, 2026 to follow the example. Enter 100000 for Initial Cash, select 1 day for Resolution, and choose Close for Price To Buy. The $100,000 is simulated cash. Each candle represents one trading day.
For your own experiment, pick the test dates before opening the results. Write them down with the rules and starting balance. If you choose the dates because you already know they contain a spectacular rally, you have learned something about that rally. A quieter period might tell a different story.

These settings reproduce the daily QQQ example. Keep them with your notes when you compare runs.Full size — QQQ Backtest panel with start and end dates, 100000 initial cash, 1 day resolution, and Close selected. (opens in a new tab) Step 3
Run the backtest and find the first order
Select Run Backtest. When Strategy Assessment appears, confirm the starting balance and the dates of the selected result. If you have several saved backtests, select the matching dates. On the price chart, find the first green QQQ marker and read the close and indicator values for that day.
If your own chart has no orders, start with one day you thought would qualify. Were both entry conditions true on that day? Was there enough price history to calculate the longer average? A run with no trades can answer the question you asked just as clearly as a busy one.
Step 4
Explain a complete trade in dollars
The example bought 237 simulated shares at $421.24 on January 19, 2024. Follow the chart to the next red marker on April 4, when it sold all 237 at $435.26. The difference was $14.02 per share, or $3,322.74 before costs. That gives you a dollar amount to check against the portfolio curve.
Now look at the rules again. Which threshold let the strategy in, and which one let it out? If a marker surprises you, check whether the block uses the Upper or Mid band and whether it compares a closing price or an intraday high. A candle can reach above a band during the day and close back below it.

Follow a green buy marker to the next red sell marker to inspect one round trip.Full size — QQQ daily price chart with green buy markers and red sell markers beneath the candles. (opens in a new tab) Step 5
Try the same rules in a different period
The QQQ example gained 25.18% from January 2024 through October 2026. A separate run with the same rules and starting cash lost 2.20% from January 2021 through December 2022. These are cumulative simulated returns over different lengths of time. Even the direction of the result changed with the dates.
For your own TBOT, set aside a later period you have never used to choose the rules. Run it once and compare the return, largest fall from a peak, and number of trades. If that result persuades you to edit the strategy, record the change and reserve fresh dates for the next test. You can now explain both what the rule did and where your evidence ends.
Further reading · QuantConnect research guide on overfitting and look-ahead bias
Frequently asked questions
How much historical data do I need?
Enough to examine the strategy's trading frequency and relevant market conditions. Ten years with six trades offers different evidence from ten years with hundreds of trades. There is no universal duration that makes a result reliable.
Does a profitable backtest mean the strategy is ready for live trading?
No. Check the implementation, assumptions, and behavior outside development first. Paper trading adds a forward observation stage, although it also has limitations. Backtested performance remains hypothetical.
Do I need to write code?
Alphavator provides visual blocks and AI assistance for supported strategy rules. You still need to understand what those rules mean and verify what the test actually simulated.
Run your first useful experiment
Start with one idea you can explain. Create a TBOT in Alphavator, review its rules, and run a historical test. Choose one trade from the results and explain why it happened. That is a concrete first step toward understanding your strategy.
Continue with how to read backtest results, how to practice with paper money, or how to create strategy rules with AI.
For education and product demonstration. Examples are hypothetical. Trading involves risk, including loss of capital.