Skip to article
XTester Help
XTester Studio

First Validation Backtest

A ready C# project for your first run: complete code, manifest, history download and a checked result without orders.

Reviewed: Applies to: 1.0.0-preview.1

What You Will Check

This ready first validation backtest is for someone who does not yet write C#. Create a folder strategy, paste the complete file, compile it and check historical candle processing.

The example counts closed bars and writes a log. It places no orders, so zero trades is the expected result. This checks installation, data and execution before adding trading rules.

The complete project was checked in isolated EngineHost 1.0.0-preview.1 on macOS: clean compilation and a Binance/Spot/BTCUSDT historical run for one hour on 2020-01-01. Its code uses no extra libraries, exchange API keys or paid AI model.

These instructions use the Studio strategy format. Check the exact version and available API before adapting them to another release, an older Tester or SDK Handbook example.

Get the Example Project

Where to open

Command Palette → XTester: New Strategy… → Create from Scratch. Choose C#, the name First Check and a separate learning folder.

Alternatively download the ZIP, extract first-check and open it with Open Saved Strategy in the wizard. It contains main.cs, the manifest, RU/EN instructions and the actual validation receipt; it includes neither price history nor the installed application.

Application screenshotXTester 1.0.0-preview.1
Strategy wizard: three ways to begin.Interface screenshot · XTester 1.0.0-preview.1
  1. Create a new strategy from scratch.
  2. Open an already saved strategy.

Download example projectZIP

A folder strategy has main.cs and xtester.strategy.json. The wizard may add service fields. When using the wizard, retain its structure and replace the complete main.cs with the code below.

first-check/
  main.cs
  xtester.strategy.json
  README.ru.md
  README.en.md
  verification.json

Complete main.cs

Open main.cs, select its entire contents and paste this complete file. Save it before compiling.

No namespace or using was omitted for the Studio folder template: the compiler supplies standard SDK imports. This is a verified strategy-file format, not a standalone .NET console project. Check exact types and signatures against the installed engine API.

OnInit receives the logger and resets the counter. OnBar handles closed bars. OnFinish reports the count. The code contains no order-submission calls.

public class UserStrategy : IStrategy
{
    private ILogger _logger = null!;
    private int _closedBars;

    public void OnInit(StrategyContext context)
    {
        _logger = context.Logger;
        _closedBars = 0;
        _logger.Info("Learning example started. No orders will be placed.");
    }

    public void OnTick(decimal? price = null) { }

    public void OnBar(ISymbolKey symbolKey, IKline kline)
    {
        _closedBars++;
        if (_closedBars == 1)
        {
            _logger.Info("The first closed bar was received.");
        }
    }

    public void OnFinish(StrategyFinishContext context)
    {
        _logger.Info("Closed bars processed: " + _closedBars);
    }
}

Manifest and Conditions

The manifest records language, entry point and example settings: C# and main.cs, Binance Spot BTCUSDT, m1 and 1000 USDT initial funds.

This is the complete manifest of the checked ZIP. With the wizard, choose the same conditions in the interface; no manual .csproj is required. Choose Bar step mode. This tutorial runs historical data.

{
  "strategy": {
    "name": "First Check",
    "language": "csharp",
    "entryPoint": "main.cs"
  },
  "simulation": {
    "exchange": "Binance",
    "market": "Spot",
    "symbol": "BTCUSDT",
    "timeframe": "m1",
    "period": {
      "from": "2020-01-01T00:00:00Z",
      "to": "2020-01-01T01:00:00Z"
    },
    "depositUsdt": 1000,
    "launchMode": "Release"
  }
}

Download Data and Run

Open Data and download Binance / Spot / BTCUSDT m1 history for 2020-01-01. The one-hour run needs candles from 00:00 through 00:59 UTC. Check actual coverage after downloading.

Steps
  1. Choose Binance, Spot, BTCUSDT and m1.
  2. Set UTC start 2020-01-01 00:00 and end 2020-01-01 01:00.
  3. Check 1000 USDT starting funds and Bar step mode.
  4. Compile Strategy and check that it reports no errors.
  5. Run the selected strategy historically and wait for completion.

If history is unavailable, resolve the download issue first. Another instrument, date or generated dataset changes the scenario being checked.

Open Simulation for the selected strategy and set the conditions below. Validation used Bar steps and ordinary modeled execution; historical prices do not make execution an exact venue reconstruction.

Check the Result

Actual validation produced 60 steps, 59 closed-bar callbacks, 0 orders and 0 trades. Closed bars processed: 59 confirmed execution of our code, beyond successful compilation.

Application screenshotXTester 1.0.0-preview.1
The lower Strategy Log panel shows startup, the first closed candle and the final line Closed bars processed: 59. The example’s source defines these messages.Interface screenshot · XTester 1.0.0-preview.1
Application screenshotXTester 1.0.0-preview.1
The report shows zero trades and unchanged strategy equity of 1,000 USDT. The dashed line is a separate BTCUSDT benchmark; it is not activity by the example.Interface screenshot · XTester 1.0.0-preview.1
  1. Run summary metrics.
  2. Equity and the comparison benchmark.

Log timestamps use historical simulation time. This example therefore shows 2020-01-01 rather than today’s computer date. A time step and an OnBar callback are distinct events; their counts differ at these selected boundaries.

Check your own conditions and log: the first messages show startup and a closed bar, and the last line reports the counter. Another period, dataset or build may produce a different count.

Zero return is not a trading-idea evaluation here: the code deliberately buys and sells nothing. Add specific entry/exit rules as a separate exercise and validate them separately.

Learning example started. No orders will be placed.
The first closed bar was received.
Closed bars processed: 59

If the Check Fails

IStrategy or StrategyContext type error: check the Studio C# template, selected project and complete file replacement. Verify the About version and available API before adding a namespace from another example.

No candles or the run will not start: check exchange, market, symbol, m1, UTC bounds and actual downloaded coverage. A symbol name in a list does not establish history availability.

Zero trades with the expected log messages is normal for this example. Missing messages call for checking the selected strategy, saved file, compilation and actual execution.

For support, retain the version, run conditions, your own runId and exact error. Another validation receipt’s run ID does not identify your project.