Home › Guides › AmiBroker Backtesting

WHY BOTS FAILFREENO ACCOUNTAUTOMATED TRADE BOTSAmiBrokerBacktestingThe arithmetic of how bots failEDUCATION ONLY | NO SIGNALSEXAMPLE NUMBERS ARE LABELLEDAUTOMATED TRADE BOTSautomatedtradebots.com
A free page on amibroker backtesting. Education only, with example numbers labelled.
WHY BOTS FAIL

AmiBroker Backtesting

Short answer

AmiBroker is a platform where a bot or strategy is written, tested and run. This page explains the general method, not the product's current features.

How a testing platform built around whole-array formulas works, and how one line can quietly use the future.

The page explains the idea in plain words, works through the arithmetic with a table, and shows how it hits grid, martingale and DCA bots, then tells you what to check before you run one.

  • A worked example with real arithmetic
  • How it hits grid, martingale and DCA bots
  • How to check for it before you run a bot
  • No advice, no signals, no profit promises

Last reviewed 28 October 2026. Education only, not advice.

Free, no account Runs in your browser Worked numbers shown Not advice Examples labelled

Ready to go further

Next: look-ahead bias

The most common reason a backtest is too good.

Reading time5 minutes
Worked exampleExact arithmetic
Tools linked0 on this page
Reviewed28 Oct 2026

What is included

  • What it is, in plain words
  • The formula or mechanism, with exact arithmetic
  • How it hits grid, martingale and DCA bots
  • A check you can run before you switch a bot on

Who it is for

  • People who run or plan to run a trading bot
  • Anyone reading a backtest or a bot sales page
  • Readers who want the numbers, not the pitch
  • Not advice, and not a signal service
Total return of the same signal traded on the signal bar or on the next bar6.8%Same barnot possible live-4.8%Next barwhat you can doMade-up prices, 9 bars. Calculated by us on 31 Oct 2026.
The picture for this page. Example numbers are made up unless the page says they were calculated.

Key facts

  • AmiBroker is a platform where a bot or strategy is written, tested and run. This page explains the general method, not the product's current features.
  • A bot is only as trustworthy as its test. Before relying on any result here, check costs, fills, data and timing, and keep a stretch of data the rule never saw.
  • The worked example on this page uses made-up numbers, checked in node on 31 Oct 2026. It shows the arithmetic, not how any product performs.
  • Prices, fees, markets, versions, limits and supported languages change and belong to the vendor. We state none of them. Check the vendor's current pages.
  • Start on a simulated account, keep stops where they still work if the bot stops, and move to real money only in very small steps, if at all.

What it is

AmiBroker is a technical analysis and testing program. Programs of this kind are known for a formula language that works on whole arrays at once: instead of looping through bars one by one, a line of code describes a calculation for every bar in the history in a single statement. That style is compact and fast for backtesting a rule across many symbols, and it has a built-in portfolio-level backtester and tools for testing a rule on rolling windows of data.

It is mainly a testing and analysis tool. Sending live orders usually goes through add-ons or bridges to a broker that you or others supply, so the live link is a separate thing from the test. What those links are, and what they cost, is for the vendors to say. Check the current pages. This page explains how it works in general terms. We have not tested it for this page. Check the vendor's current terms.

How a bot connects here

The connection style is built-in scripting for the test and a bridge for live orders.

  • Array thinking. A signal is an array of true and false, one per bar. Shifting an array forward or backward in time is easy to do the wrong way round.
  • Trade timing settings. A backtest can be told whether to trade on the signal bar or later, at the open or close. This setting is as important as the rule.
  • Portfolio backtest. Position limits, ranking and costs apply across symbols.
  • Bridge to live. A separate piece of software translates signals into orders. It is a different program with different failure modes.

Worked example: one signal, two timings

A made-up rule: if a bar closes above its own open, it was an up bar, and the rule goes long for one bar. That fact is known only at the close. Version A buys at that bar's open and sells at its close, so it trades a bar it could only recognise after the bar had ended. Version B waits and trades the next bar, open to close, which is what a real order can do. Both use the same 9 made-up bars and were checked in node.

Signal barA: same bar, open to closeA: returnB: next bar, open to closeB: return
Bar 1101 to 1020.99%103 to 101-1.94%
Bar 3102 to 1052.94%106 to 104-1.89%
Bar 5105 to 1082.86%104 to 103-0.96%
Total6.79%-4.79%

Version A adds up to 6.79% and version B to -4.79%. The only difference is when the trade is allowed to happen. Version A uses the close of a bar to decide a trade that began at its open, which no one can do. This is look-ahead bias, covered in its own guide. In an array language the same mistake can hide in a single reference to a future bar. If a backtest looks too good, the first thing to check is whether any value used on a bar could not have been known at that bar.

Total return of the same signal traded on the signal bar or on the next bar6.8%Same barnot possible live-4.8%Next barwhat you can doMade-up prices, 9 bars. Calculated by us on 31 Oct 2026.
Total return of the same signal traded on the signal bar or on the next bar. All numbers are made up or calculated for illustration.

What to verify before trusting a backtest here

These checks apply to any platform of this kind. The answers come from the vendor's current documentation and from your own tests, not from this page.

CheckWhy it matters
Trade timing settingSignals known at the close should trade at the next bar, not the same one.
References to future array elementsSearch the code for any shift that pulls tomorrow into today.
Costs and slippage per tradeEnter them. See slippage.
Data adjustmentsSplits and dividends change past prices. Know which version you tested on.
Symbol list chosen in hindsightSee survivorship bias.
Rolling window testsSee walk forward testing.

How bots break on this kind of platform

  • Look-ahead. The test knows something live cannot.
  • Bridge failure. Signals do not reach the broker, or arrive twice.
  • Mismatch between test and live logic. The bridge version is a rewrite.
  • Data differences. Adjusted data in test, raw prices live.
  • Overfitting by speed. Fast tests invite thousands of tries. See overfitting.

A safe order of work

Backtest with honest costs, forward test on new data, run on a simulated account for weeks, then trade a very small size and compare each step with the one before. See forward testing and paper trading.

What this page does not tell you

It does not tell you whether the product is suitable, what it costs, or how it behaves today. Those change and belong to the vendor. It does not give a strategy to trade. This page explains how it works in general terms. We have not tested it for this page. Check the vendor's current terms.

FAQ

Frequently Asked Questions

What is AFL?

The array-based formula language used by programs of this type. A statement works on a whole array of bars at once. Check the vendor for current details.

Can AmiBroker place live trades?

Programs of this kind often reach a broker through add-ons or bridges. What is supported is for the vendor and the add-on makers to say.

Does a good AmiBroker backtest mean a bot will make money?

No. A backtest shows how a rule behaved on past data under its assumptions. Costs, fills, data and luck can all make live results different.

Should I test on a simulated account before real money?

Yes, as a general practice. A simulated account tests your code and your plumbing. Its fills are usually kinder than real ones, so it does not prove a rule works.

Have you tested AmiBroker?

No. This page explains how it works in general terms and we have not tested it for this page. Check the vendor's current terms.

Are the numbers on this page real?

Example numbers are made up to show how the maths works, and the page says so. A figure only counts as exact when the page says it was calculated on a stated date. Nothing you enter in a calculator leaves your browser.

Can I use this to decide whether to run a bot?

It can show whether a bot's numbers hold together and how much an account can lose. It cannot say what the market will do, and it is not advice. Use it to ask better questions, then read the terms of your own broker or exchange.

Is this financial advice?

No. It is general education. The numbers are made up and it does not consider your situation.

Know the Risk Before You Run It

Free calculators and guides, added every week. Leave your details and we will email you when new ones go up.

Trading carries a risk of loss