Learn › Backtesting without code

How to Backtest a Trading Strategy Without Code

A backtest applies a fixed set of trading rules to historical market data and records what those rules would have done: every buy and sell, the value of the account along the way, and what it cost. Code is one way to write the rules down. A visual builder is another — the same conditions, joined with AND, OR and NOT, wired together instead of typed.

What a backtest measures

A backtest answers a narrow question: what would these exact rules have done on this data, over this period, at these costs? Its output is a record of trades and an equity curve — the account's value at every point in the test.

It describes the past. A backtest is not a forecast: a rule that worked on one decade of one stock is evidence about that decade and that stock. Its value comes from making an idea specific enough to measure, so it can be compared, repeated and questioned.

1. State the idea as a question

Start from something a chart, a book or a post suggests, and write it as a question with a comparison in it. For example: did buying when the 14-day RSI fell below 30, and selling when it rose back above 70, do better than simply holding the same stock over the same years?

The comparison is part of the question. "It made money" is a weak result when holding the stock made more with less effort; the question decides what the result is measured against.

2. Turn it into exact rules

A rule is testable when a computer could apply it without asking you anything. Each strategy needs:

Vague words are where tests go wrong. "When RSI is low" has no threshold; "a strong breakout" has no definition. Each has to become a number, a crossing or a comparison between two lines. A rule must also be computable on the candle it fires: using a value that only becomes known later (the day's close, before the close has happened) is look-ahead bias, and it makes any strategy look better than it could ever have been.

3. Build the rules without code

In a visual strategy builder the rule is a diagram. Each condition is a block — RSI < 30, Close crosses above the 50-day SMA, a candlestick pattern — and blocks are joined through logic gates:

The diagram is the rule: what is wired is what runs, so there is no second description of the strategy to keep in step with the code.

4. Choose the instruments, the period and the timeframe

Survivorship bias belongs here too: testing only on companies that exist today leaves out the ones that failed or were delisted, which flatters most strategies.

5. Include costs

Every trade pays something: commission, the bid–ask spread, and slippage between the price you expected and the price you got. A rule that trades often can turn a small gross gain into a net loss. Include a fee per trade at a level you consider realistic; a zero-cost run is useful as a comparison, to see how much the costs changed the result.

6. Read the results

A single number rarely describes a strategy. Read these together:

A high return on its own does not establish that a strategy is useful. It has to be read against a benchmark.

7. Compare with a benchmark

The benchmark is whatever the question compared against — most often, buying the same instrument at the start and holding it to the end. Build that as its own strategy and run it over the same period, at the same costs. Then compare return, drawdown and time in the market side by side.

The Test Bench's first study is a worked example. It ran three Donchian Channel breakout rules on 179 US stocks over eight years and compared each with holding the stock; its central finding is that profitable is not the same as better.

The RSI mean reversion backtest does the same for four RSI entries under one rule, each set beside buying and holding and beside its own time in the market.

8. Check that the result holds up

Overfitting is what happens when a rule is adjusted, again and again, until it fits the history it is being tested on. Each change that improves the backtest is kept; the final rule describes the past very well and the future no better than chance. The more variations tried, the more likely one looks good by luck — the problem of multiple comparisons.

Common checks against it:

Common mistakes

Common questions

Can a trading strategy be backtested without writing code?

Yes. A backtest needs exact rules, not a programming language. In a visual builder the same logic — conditions, AND, OR and NOT, entries and exits — is wired together as a diagram, and what is wired is what runs.

What logic can a visual strategy builder express?

In GU Analyser: conditions on 60+ indicators and price, compared with a number or with another line, including crossovers; AND, OR and NOT gates; buy, sell and partial-sale (trim) terminals; exits on a percentage gain, a stop loss or a number of bars held; and exits at the end of the session or the week. Premium adds candlestick-pattern conditions and timing windows.

How are fees handled in a backtest?

As a percentage per buy and per sell, deducted from each trade. Every trade fills at the close of the candle on which its rule fires. Slippage and the spread are not modelled separately, so a fee that includes them is the conservative setting.

How much history can a strategy be tested on?

On GU Analyser’s own data, about ten years of daily bars and about 1.3 years of hourly bars. With your own Tiingo key on Premium, up to 20 years of daily bars (and weekly bars built from them), about three years of hourly bars and about six months of five-minute bars.

Does a strong backtest mean a strategy will work?

No. A backtest describes what a rule did on past data under stated assumptions; it is not a forecast. A rule tuned until it fits one period can fail on the next, which is why out-of-sample checks and a benchmark matter.

Doing this in GU Analyser

GU Analyser's strategy canvas is the visual builder described above: Signal blocks for conditions on any of its 60+ indicators and on price; Logical blocks for AND, OR and NOT; BUY, SELL and TRIM terminals; Position exits for a percentage gain, bars held or a stop loss; and Time exits for the end of the session or the week. Premium adds candlestick-pattern conditions and timing windows for conditions that do not line up on the same candle.

For the indicators most often used in first strategies, the reference pages explain what each measures: RSI, MACD, Simple Moving Average, Bollinger Bands and Donchian Channel. To study what followed a single condition rather than a full strategy, see event analysis.

Build and test it yourself

GU Analyser is where this method can be carried out: build the rules on a visual canvas, run them against historical data and inspect the return, drawdown, time in the market and fees — free on the S&P 500 ETF, no card.

Create a free account → or start with the courses →
This is educational material, not advice. It describes methods and conventions used to study markets on historical data. Nothing here is a recommendation to buy or sell anything, and a historical test does not show what will happen next. GU Analyser is an analytical and educational tool — no money is ever traded here.