cTrader backtesting guide

cTrader backtesting: how to test a cBot

A useful cTrader backtest starts with explicit trading rules and a cBot that builds. This workflow takes you from a written strategy to historical testing, then separates that result from demo and live trading.

Direct answer

cTrader backtesting runs a cBot against historical market data in cTrader Windows or Mac, or through the official cTrader CLI. Build the cBot, add an instance, choose the Backtesting tab, set the test conditions, and inspect the report. Pineify can generate or revise the C# source and return compiler diagnostics, but it does not execute the backtest.

What to know first

  • cTrader backtests cBots. A custom indicator cannot be backtested directly, although a cBot can reference its output.
  • A clean compiler check confirms that the source builds against the supported API contract. It does not test trading behavior.
  • Record the symbol, timeframe, date range, data source, costs, starting balance, and cBot parameters before comparing runs.
  • Historical results do not guarantee future performance. Check untouched data and a demo account before considering live use.

Compile, backtest, demo, and live are different checks

StageWhat it can tell youWhat it cannot tell you
CompileWhether the C# source passes compiler and supported cTrader API checks.Whether the trading rules behave as intended or produce useful results.
BacktestHow one cBot version behaves on selected historical data and settings.How the same cBot will perform on unseen or future market data.
DemoHow the cBot behaves over incoming market data with virtual funds.How every live order will fill or what future returns will be.
LiveThe cBot outcome under actual account, market, and execution conditions.Any guarantee that past behavior will continue.

Write the rules before you write the cBot

Start with a test specification that another person could follow. Define the entry event, exit event, position limits, volume rule, protective stops, and the conditions that block a trade. State whether each decision happens on a tick, on a new bar, or after a bar closes.

Keep trading rules separate from test settings. The cBot owns signal and risk logic. cTrader supplies the symbol, timeframe, historical period, data source, spread, commission, starting balance, and parameter values for a particular run.

  • Use conditions that can be expressed in code and checked on a chart.
  • Decide how the cBot identifies its own positions before it opens or closes a trade.
  • List assumptions about missing bars, spread, commission, and order failures for later review.

Generate and review the C# cBot

Pineify can turn the written rules into an editable C# cBot or revise an existing source file. Ask for named parameters where you expect to test different inputs, and keep position handling explicit so the resulting trades are easier to explain.

Read the generated source before testing it. Check the cBot lifecycle methods, indicator initialization, signal timing, order calls, position filters, and stop logic against the specification. Pineify does not generate a backtest result and does not run cTrader inside the website.

  • Confirm that entry and exit rules use the intended bar or tick event.
  • Check that every order path applies the intended position and risk limits.
  • Remove behavior that is not present in the written test specification.

Clear compiler diagnostics first

Run Pineify compiler checking on the current C# source and fix every reported diagnostic. Then move the reviewed source into cTrader Windows or Mac, save it, and build the cBot there before adding an instance.

Compilation is a narrow gate. It catches C# and supported cTrader API errors, but it cannot tell whether a crossover fires on the intended bar, whether the risk rule is suitable, or whether a strategy will make money. Those questions require behavior checks and testing.

Run the backtest in cTrader

In cTrader Windows or Mac, select a built cBot instance and open its Backtesting tab. Set the date range and test conditions, then choose a normal run for the final report or Visual mode when you need to watch trades appear against historical price action.

The official cTrader CLI can also run a backtest from a built .algo file. Its backtest command accepts a period, symbol, data mode, account details, and optional cost or report settings. Use the desktop interface for interactive inspection and the CLI when a repeatable terminal workflow fits the job.

  • Keep the same test conditions when comparing two code or parameter versions.
  • Inspect trades, orders, history, events, and the cBot log instead of reading one summary number.
  • Save the cTrader HTML or CLI report with the code version and settings that produced it.

Check untouched data, then use a demo account

Reserve a later historical period before tuning. Once you choose the rules and parameters, run them on that untouched period without another round of selection. A large drop in behavior is a reason to inspect the assumptions, not a reason to keep tuning the holdout.

After historical checks, run the same cBot on a cTrader demo account and compare its actions with the specification. Demo trading can expose timing, state, and operational behavior that a completed historical report does not show. It still does not predict live results.

Practical checks I use

I freeze the test specification

I write down the code version, symbol, timeframe, dates, data source, costs, starting balance, and parameters before comparing runs. Otherwise I cannot tell which change caused the difference.

When I change logic, I watch it

When I alter an entry or exit rule, I use Visual mode and the cBot log before studying the summary. I want to see whether each trade matches the written rule.

I protect the holdout period

I keep a later date range out of the tuning process. I run it after the rules are fixed and do not select another parameter set from the same holdout result.

Primary sources

Pineify is an information tool, not investment advice. It generates and modifies cTrader C# and provides compiler diagnostics, but it does not run cTrader backtests or place trades. Backtest results are historical simulations, not promises of future performance. Review the code, test on unseen data, and use a demo account before considering live trading.

Frequently asked questions

Turn your test specification into a cBot

Describe the entry, exit, position, and risk rules. Pineify generates editable C# and helps fix compiler diagnostics before you run the backtest in cTrader.

Build cTrader C#