Methodology and Prompt Guide

Backtesting, Explained Clearly

The backtester converts a natural-language strategy into explicit indicators, entry rules, exit rules, and risk controls, then evaluates those rules against historical IBKR candles.

Video walkthrough

Backtesting Walkthrough

Watch a practical walkthrough before reading the full assumptions, defaults, limitations, and prompt templates.

Important limitations

A backtest is a simplified historical simulation, not a forecast.

  • Only one ticker and one open position are supported per run.
  • Candle data cannot reveal the exact intrabar path. If a stop and target are both touched, the stop is assumed to occur first.
  • Liquidity, bid-ask spread, partial fills, queue position, and market impact are not simulated.
  • Short borrow availability, borrow fees, margin interest, taxes, and funding costs are not modeled.
  • Slippage and commissions are fixed assumptions, not predictions of actual execution costs.
  • The AI may misunderstand a strategy. Always inspect the parsed strategy shown with the results.

How a Backtest Runs

1

Parse

Convert your prompt into a structured strategy.

2

Load

Request historical OHLCV candles from IBKR.

3

Simulate

Generate signals and model entries, exits, and costs.

4

Report

Return trades, metrics, and a mark-to-market equity curve.

Defaults and Configurable Inputs

State important values explicitly in your prompt. When they are omitted, the following defaults apply.

VariableDefaultHow it is used
TickerRequiredOne instrument per backtest
Timeframe1 hourCandle interval used for signals and annualization
Test period1 yearSubject to the server candle limit
Initial capital$100,000Starting account equity
Risk per trade1%Capital risk budget divided by stop distance
Slippage5 basis pointsApplied adversely to every entry and exit
Commission$1 per orderCharged on both entry and exit
Stop loss2% or 2 ATRATR is used when included; otherwise percentage
Take profit3% or 3 ATRATR is used when included; otherwise percentage
Maximum exposure100% of equityPrevents position size from exceeding available capital
End of testClose positionAny remaining position is liquidated on the final close
The server currently permits a maximum of 5,000 candles per backtest. If the requested period would exceed that budget, the period is shortened before IBKR is queried. The results display the requested period, retrieved period, and candles used.

Signal, Entry, and Exit Assumptions

Signal generation

  • Indicators use completed historical candles.
  • All long-entry conditions must be true together.
  • All short-entry conditions must be true together.
  • Any configured exit condition can trigger an exit.
  • Crossovers compare the previous and current candle values.

Execution model

  • A signal formed at a close executes at the next candle open.
  • Adverse slippage is added to buys and deducted from sells.
  • Stop losses and targets are checked against candle high and low.
  • Gaps beyond a stop or target are filled at the candle open.
  • A position is marked to market using each candle close.

Position Sizing and Capital

Position size is the smaller of the risk-based size and the capital-affordable size. The engine uses whole shares and does not introduce leverage by default.

Risk budget

equity x risk per trade

Risk-based size

risk budget / stop distance

Final size

min(risk size, affordable size)

Supported Technical Indicators

Indicator periods and parameters can be stated in the prompt. Multi-output indicators can be used through components such as MACD signal, Bollinger upper/lower bands, Aroon Up/Down, and directional indicators.

Moving Averages and Price

  • EMA - Exponential Moving Average
  • SMA - Simple Moving Average
  • WMA - Weighted Moving Average
  • HMA - Hull Moving Average
  • TEMA - Triple Exponential Moving Average
  • DEMA - Double Exponential Moving Average
  • ZLMA - Zero Lag Moving Average
  • VWAP - Volume Weighted Average Price

Momentum

  • RSI - Relative Strength Index
  • Stochastic Oscillator
  • Stochastic RSI
  • Williams %R
  • Awesome Oscillator
  • Rate of Change
  • Percentage Price Oscillator
  • Ultimate Oscillator
  • TRIX
  • True Strength Index
  • Money Flow Index

Volatility and Channels

  • Average True Range
  • Bollinger Bands
  • Keltner Channels
  • Donchian Channels
  • Mass Index
  • Ulcer Index

Trend

  • ADX and Directional Indicators
  • MACD
  • Aroon
  • Vortex Indicator
  • Choppiness Index
  • Parabolic SAR
  • Supertrend

Volume

  • On-Balance Volume
  • Chaikin Money Flow
  • Ease of Movement
  • Klinger Volume Oscillator
  • Price-Volume Trend

Results and Metrics

Total return

Final equity relative to starting capital.

Sharpe ratio

Candle-return Sharpe annualized for the selected timeframe, with a zero risk-free rate.

Maximum drawdown

Largest peak-to-trough decline in the equity curve.

Win rate

Percentage of completed trades with positive net P&L.

Profit factor

Gross profitable trade P&L divided by gross losing trade P&L.

Average trade P&L

Mean net P&L across completed trades.

Total commission

Entry and exit commissions across completed trades.

Equity curve

Realized capital plus open-position P&L at each candle close.

Trade log

Entry, exit, size, costs, net P&L, and exit reason.

Prompt Template

Backtest a [long-only / short-only / long and short] strategy on [TICKER]
using [TIMEFRAME] candles for [PERIOD].

Indicators:
- [Indicator name and parameters]
- [Indicator name and parameters]

Entry:
- [Condition 1]
- [Condition 2]

Exit:
- [Exit condition 1]
- Or [exit condition 2]

Use:
- [Initial capital]
- [Risk per trade]
- [Stop-loss rule]
- [Take-profit rule]
- [Slippage]
- [Commission per order]

More explicit prompts produce more auditable configurations. Review the parsed strategy before interpreting the results.

Ready-to-Use Examples

MACD crossover

Simple
Backtest a long-only MACD crossover strategy on AAPL using daily candles for the past 2 years.

Entry:
- Buy when MACD crosses above its signal line.

Exit:
- Sell when MACD crosses below its signal line.

Use a 2% stop loss and 4% take profit.

Bollinger Bands

Mean Reversion
Backtest a long-only Bollinger Bands mean-reversion strategy on TSLA using 1-hour candles for the past 6 months.

Use Bollinger Bands with a 20-period moving average and 2 standard deviations.

Entry:
- Buy when the closing price crosses below the lower Bollinger Band.

Exit:
- Sell when the closing price crosses above the middle Bollinger Band.

Use:
- $100,000 initial capital
- 1% risk per trade
- 2% stop loss
- 4% take profit
- 5 basis points slippage
- $1 commission per order

Volume, momentum, and trend

Multi-Indicator
Backtest a long-only strategy on AAPL using daily candles for the past 2 years.

Use Chaikin Money Flow with a 20-period length, RSI with a 14-period length, and EMA with a 50-period length.

Entry:
- Buy when Chaikin Money Flow crosses above 0
- RSI is below 60
- Closing price is above the 50-period EMA

Exit:
- Sell when Chaikin Money Flow crosses below 0
- Or when RSI crosses above 70

Use $100,000 initial capital, 1% risk per trade, a 3% stop loss, a 6% take profit, 5 basis points slippage, and $1 commission per order.

Read Before Relying on Results

  • Past performance does not predict future performance.
  • Results depend on the quality and availability of IBKR data.
  • Only one ticker is tested; portfolio effects are excluded.
  • No walk-forward analysis, optimization, or Monte Carlo simulation is performed.
  • Corporate events and changing market regimes may distort comparisons.
  • Actual fills and costs can differ materially from modeled values.
  • AI-generated rules can be incomplete or incorrectly interpreted.
  • Backtests are research tools, not investment advice or trade recommendations.