For traders and strategy developers
Test your trading idea
on historical data
Define your strategy rules and see which trades it would have made. Review entries, exits and drawdown before moving to live trading. XTester Studio runs on your computer and is free to use. Write the code yourself or with AI help. To run a finished bot, explore Launcher.
Download XTesterStart opens the live chart. Report shows trades and drawdown. Changing language resets the demo.
MARKET DATA
Data from 20 exchanges and 3 DEXs
Download history for the instrument you need and test your strategy on it. Spot and futures data are available, including linear and inverse contracts.
Available instruments and history depth vary by exchange.
01 / Your rules
Define your entry and exit rules
Start from a template or import a file, folder or Git repository. Set when to open and close trades, how much to trade and how to limit risk. You can read and change the code at any time.
C# has the fullest support. The other language adapters are experimental; Pine support is partial. Browse source templates →
- 01Entry condition
When should the strategy open a trade?
- 02Position size
How much will it trade?
- 03Exit & risk limits
When should it close a position, and what risk limits should apply?
02 / Test and compare
See which trades make up the result
Review entry and exit points, costs and drawdown. Change the parameters and compare versions of the strategy. Then test on a period you did not use while refining it.
The example above uses generated candles. Its trades and decision log let you trace the calculation, but its result does not show returns on historical data. Run and inspect the example ↑
03 / AI alongside your code
Work through a strategy rule with AI
Ask the assistant to explain why the strategy opens a trade or help with an error in the code. If you already use Claude Code, Codex, Claude Desktop or Cursor, connect your client to XTester Studio through MCP.
Projects and downloaded history are stored on your computer. Cloud AI receives the data you send it. You must approve an external agent connection in the app.
MCP / Claude Code · Codex · Claude Desktop · Cursor
Connect AI agents / MCP
Choose an AI client and prepare a configuration for your installed XTester Studio. You can also browse the MCP tools and open the connection guide here.
Set up an AI client
From the first test to your own bot
Start by testing your strategy
Version: 1.0.0-preview.2 · Windows · macOS · Linux
Source templates, ready to inspect
Download a starter file in your chosen language and add your strategy rules. C# has the fullest support. The other adapters are experimental, and Pine support is partial.
- C#
- Python
- JavaScript
- TypeScript
- Java
- C++
- Rust
- Go
- R
- Pine Script
Choose a language and open the source
main.cs
Core runtimeDownloadA starter file for XTester Studio. Add your entry and exit rules in the bar callback. Source
public class UserStrategy : IStrategy
{
// Services available to the strategy: orders, indicators, parameters,
// market data, and logging.
private IApi _api = null!;
private IIndicators _indicators = null!;
private IStrategyParams _params = null!;
private IMarketData _marketData = null!;
private ILogger _logger = null!;
public void OnInit(StrategyContext context)
{
_api = context.Api;
_indicators = context.Indicators;
_params = context.Parameters;
_marketData = context.MarketData;
_logger = context.Logger;
_logger.Info("UserStrategy initialized.");
}
public void OnTick(decimal? price = null)
{
}
// Called for every closed bar in every subscription.
// symbolKey identifies the exchange, market, pair, and timeframe.
public void OnBar(ISymbolKey symbolKey, IKline kline)
{
}
// Called exactly once when a Tester, Paper, or Live run finishes.
public void OnFinish(StrategyFinishContext context)
{
}
}main.py
Experimental SDK bridgeDownloadA starter file for XTester Studio. Add your entry and exit rules in the bar callback. Source
# Add your decisions in on_bar. self.context.api places orders (buy, sell, place_order,
# close_position); self.context.indicators reads the engine's indicators (rsi, sma, ema,
# macd, call("ADX", period=14)); self.context.logger writes to the strategy log.
from xtester import Strategy, OrderSide, OrderType
class UserStrategy(Strategy):
# symbol_key: exchange, market, symbol, timeframe of the closed bar.
# bar: open_time, close_time, open, high, low, close, volume as Decimal.
def on_init(self, context):
context.logger.info("UserStrategy initialized.")
def on_tick(self, price):
pass
def on_bar(self, symbol_key, bar):
pass
def on_finish(self, context):
pass
def create_strategy():
return UserStrategy()main.mjs
Experimental SDK bridgeDownloadEducational Tester example: one market buy on a bullish candle, one close request on a later bearish candle. One symbol, initially flat; acceptance is not a fill. Not for live trading. Source
// EDUCATIONAL TESTER EXAMPLE — one symbol, initially flat; not for live trading.
// First bullish candle: attempt a 0.01 market buy. First later bearish candle:
// attempt to close the whole position. At most one entry and one exit request.
// Acceptance is not a fill; errors stop the example. No retries, restart recovery,
// position reconciliation or risk controls. Choose valid size/funds in Studio.
// GETTING STARTED
// 1. Open Data and download candles for an exchange, market, and symbol.
// 2. Press F5: the XTester engine runs this strategy over the project's candles and
// executes orders, fees and balances itself; this file only decides.
// 3. Add your decisions in onBar. this.context.api places orders (buy, sell, placeOrder,
// closePosition); this.context.indicators reads the engine's indicators (rsi, sma, ema,
// macd, call('ADX', { period: 14 })); this.context.logger writes to the strategy log.
// Ask the AI assistant to explain this file.
import { Strategy, OrderSide, OrderType } from 'xtester';
export class UserStrategy extends Strategy {
phase = 0;
// symbolKey: exchange, market, symbol, timeframe of the closed bar.
// bar: openTime, closeTime, open, high, low, close, volume as numbers (bar.text.* keeps the exact decimals).
onInit(context) {
context.logger.info('UserStrategy initialized.');
}
onTick(price) {
}
onBar(symbolKey, bar) {
if (this.phase === 0 && bar.close > bar.open) {
const result = this.context.api.buy('0.01');
this.phase = result.success ? 1 : 2;
if (!result.success) this.context.logger.info(result.errorMessage);
} else if (this.phase === 1 && bar.close < bar.open) {
const result = this.context.api.closePosition();
this.phase = 2;
if (!result.success) this.context.logger.info(result.errorMessage);
}
}
onFinish(context) {
}
}
export function createStrategy() {
return new UserStrategy();
}
main.ts
Experimental SDK bridgeDownloadA starter file for XTester Studio. Add your entry and exit rules in the bar callback. Source
// The XTester engine type-checks this strategy, runs it over the project's candles
// and executes orders, fees and balances itself; this file only decides.
import { Strategy, OrderSide, OrderType, type Bar, type Context, type SymbolKey } from 'xtester';
export class UserStrategy extends Strategy {
// symbolKey: exchange, market, symbol, timeframe of the closed bar.
// bar: openTime, closeTime, open, high, low, close, volume as numbers.
onInit(context: Context): void {
context.logger.info('UserStrategy initialized.');
}
onTick(price: number | undefined): void {
}
onBar(symbolKey: SymbolKey, bar: Bar): void {
}
onFinish(context: Context): void {
}
}
export function createStrategy(): UserStrategy {
return new UserStrategy();
}main.java
Experimental SDK bridgeDownloadEducational Tester example: one market buy on a bullish candle, one close request on a later bearish candle. One symbol, initially flat; acceptance is not a fill. Not for live trading. Source
// EDUCATIONAL TESTER EXAMPLE — one symbol, initially flat; not for live trading.
// First bullish candle: attempt a 0.01 market buy. First later bearish candle:
// attempt to close the whole position. At most one entry and one exit request.
// Acceptance is not a fill; errors stop the example. No retries, restart recovery,
// position reconciliation or risk controls. Choose valid size/funds in Studio.
// GETTING STARTED
// 1. Open Data and download candles for an exchange, market, and symbol.
// 2. Press F5: the XTester engine runs this strategy over the project's candles and
// executes orders, fees and balances itself; this file only decides. A JDK is needed:
// Studio offers the Java language pack when none is installed.
// 3. Add your decisions in onBar. context.api() places orders (buy, sell, placeOrder,
// closePosition); context.indicators() reads the engine's indicators (rsi, sma, ema,
// macd, call("ADX", "period", 14)); context.logger() writes to the strategy log.
// Ask the AI assistant to explain this file.
import xtester.Bar;
import xtester.Context;
import xtester.Strategy;
import xtester.SymbolKey;
import java.math.BigDecimal;
class UserStrategy extends Strategy {
private int phase = 0;
@Override
public void onInit(Context context) {
context.logger().info("UserStrategy initialized: " + context.parameters().symbolKey());
}
@Override
public void onTick(BigDecimal price) {
}
@Override
public void onBar(SymbolKey symbolKey, Bar bar) {
if (phase == 0 && bar.close().compareTo(bar.open()) > 0) {
var result = context.api().buy("0.01");
phase = result.success() ? 1 : 2;
if (!result.success()) context.logger().info(result.errorMessage());
} else if (phase == 1 && bar.close().compareTo(bar.open()) < 0) {
var result = context.api().closePosition();
phase = 2;
if (!result.success()) context.logger().info(result.errorMessage());
}
}
@Override
public void onFinish(Context context) {
}
}
main.cpp
Experimental SDK bridgeDownloadEducational Tester example: one market buy on a bullish candle, one close request on a later bearish candle. One symbol, initially flat; acceptance is not a fill. Not for live trading. Source
// EDUCATIONAL TESTER EXAMPLE — one symbol, initially flat; not for live trading.
// First bullish candle: attempt a 0.01 market buy. First later bearish candle:
// attempt to close the whole position. At most one entry and one exit request.
// Acceptance is not a fill; errors stop the example. No retries, restart recovery,
// position reconciliation or risk controls. Choose valid size/funds in Studio.
// GETTING STARTED
// 1. Open Data and download candles for an exchange, market, and symbol.
// 2. Press F5 inside a project: the XTester engine compiles every .cpp of this folder with the
// header-only xtester.hpp and runs it over the project's candles, executing orders, fees and
// balances itself; this file only decides. A C++ compiler is needed (Xcode CLT, clang/g++).
// 3. Add your decisions in onBar. ctx.api places orders (buy, sell, placeOrder, closePosition);
// ctx.indicators reads the engine's indicators (rsi, sma, ema, call("ADX", ...)); ctx.logger
// writes to the strategy log. XTESTER_STRATEGY defines main: never write main yourself.
// Ask the AI assistant to explain this file.
#include "xtester.hpp"
class UserStrategy : public xtester::Strategy {
int phase = 0;
void onInit(xtester::Context& ctx) override {
ctx.logger.info("UserStrategy initialized: " + ctx.parameters.symbolKey.str());
}
void onTick(xtester::Context& ctx, std::optional<double> price) override {
}
void onBar(xtester::Context& ctx, const xtester::SymbolKey& symbolKey, const xtester::Bar& bar) override {
if (phase == 0 && bar.close > bar.open) {
auto result = ctx.api.buy("0.01");
phase = result.success ? 1 : 2;
if (!result.success) ctx.logger.info(result.errorMessage);
} else if (phase == 1 && bar.close < bar.open) {
auto result = ctx.api.closePosition();
phase = 2;
if (!result.success) ctx.logger.info(result.errorMessage);
}
}
void onFinish(xtester::Context& ctx) override {
}
};
XTESTER_STRATEGY(UserStrategy)
main.rs
Experimental SDK bridgeDownloadEducational Tester example: one market buy on a bullish candle, one close request on a later bearish candle. One symbol, initially flat; acceptance is not a fill. Not for live trading. Source
// EDUCATIONAL TESTER EXAMPLE — one symbol, initially flat; not for live trading.
// First bullish candle: attempt a 0.01 market buy. First later bearish candle:
// attempt to close the whole position. At most one entry and one exit request.
// Acceptance is not a fill; errors stop the example. No retries, restart recovery,
// position reconciliation or risk controls. Choose valid size/funds in Studio.
// GETTING STARTED
// 1. Open Data and download candles for an exchange, market, and symbol.
// 2. Press F5 inside a project: the XTester engine builds this folder as a crate around the
// xtester SDK and runs it over the project's candles, executing orders, fees and balances
// itself; this file only decides. A Rust toolchain is needed: Studio offers the Rust language pack.
// 3. Add your decisions in on_bar. ctx.api places orders (buy, sell, place_order, close_position);
// ctx.indicators reads the engine's indicators (rsi, sma, ema, call("ADX", ...)); ctx.logger
// writes to the strategy log (println! breaks the protocol). The engine generates main.
// Ask the AI assistant to explain this file.
use xtester::*;
#[derive(Default)]
struct UserStrategy { phase: u8 }
impl Strategy for UserStrategy {
fn on_init(&mut self, ctx: &Context) {
ctx.logger.info(format!("UserStrategy initialized: {}", ctx.parameters.symbol_key));
}
fn on_tick(&mut self, ctx: &Context, price: Option<f64>) {
}
fn on_bar(&mut self, ctx: &Context, symbol_key: &SymbolKey, bar: &Bar) {
if self.phase == 0 && bar.close > bar.open {
let result = ctx.api.buy("0.01");
self.phase = if result.success { 1 } else { 2 };
if !result.success { ctx.logger.info(result.error_message); }
} else if self.phase == 1 && bar.close < bar.open {
let result = ctx.api.close_position(None, None);
self.phase = 2;
if !result.success { ctx.logger.info(result.error_message); }
}
}
fn on_finish(&mut self, ctx: &Context) {
}
}
pub fn create_strategy() -> Box<dyn Strategy> {
Box::new(UserStrategy::default())
}
main.go
Experimental SDK bridgeDownloadEducational Tester example: one market buy on a bullish candle, one close request on a later bearish candle. One symbol, initially flat; acceptance is not a fill. Not for live trading. Source
// EDUCATIONAL TESTER EXAMPLE — one symbol, initially flat; not for live trading.
// First bullish candle: attempt a 0.01 market buy. First later bearish candle:
// attempt to close the whole position. At most one entry and one exit request.
// Acceptance is not a fill; errors stop the example. No retries, restart recovery,
// position reconciliation or risk controls. Choose valid size/funds in Studio.
// GETTING STARTED
// 1. Open Data and download candles for an exchange, market, and symbol.
// 2. Press F5 inside a project: the XTester engine builds this folder (package main) with the
// xtester SDK and runs it over the project's candles, executing orders, fees and balances
// itself; this file only decides. A Go toolchain is needed: Studio offers the Go language pack.
// 3. Add your decisions in OnBar. ctx.Api places orders (Buy, Sell, PlaceOrder, ClosePosition);
// ctx.Indicators reads the engine's indicators (RSI, SMA, EMA, Call("ADX", ...)); ctx.Logger
// writes to the strategy log. Do not write func main: the engine generates it.
// Ask the AI assistant to explain this file.
package main
import (
"fmt"
"xtester"
)
type UserStrategy struct {
xtester.Base
phase int
}
func init() { xtester.Register(func() xtester.Strategy { return &UserStrategy{} }) }
func (s *UserStrategy) OnInit(ctx *xtester.Context) {
ctx.Logger.Info(fmt.Sprintf("UserStrategy initialized: %s", ctx.Parameters.SymbolKey))
}
func (s *UserStrategy) OnTick(ctx *xtester.Context, price *float64) {
}
func (s *UserStrategy) OnBar(ctx *xtester.Context, symbolKey xtester.SymbolKey, bar xtester.Bar) {
if s.phase == 0 && bar.Close > bar.Open {
result := ctx.Api.Buy("0.01")
if result.Success { s.phase = 1 } else { s.phase = 2; ctx.Logger.Info(result.ErrorMessage) }
} else if s.phase == 1 && bar.Close < bar.Open {
result := ctx.Api.ClosePosition(nil, "")
s.phase = 2
if !result.Success { ctx.Logger.Info(result.ErrorMessage) }
}
}
func (s *UserStrategy) OnFinish(ctx *xtester.Context) {
}
main.r
Experimental SDK bridgeDownloadEducational Tester example: one market buy on a bullish candle, one close request on a later bearish candle. One symbol, initially flat; acceptance is not a fill. Not for live trading. Source
# EDUCATIONAL TESTER EXAMPLE — one symbol, initially flat; not for live trading.
# First bullish candle: attempt a 0.01 market buy. First later bearish candle:
# attempt to close the whole position. At most one entry and one exit request.
# Acceptance is not a fill; errors stop the example. No retries, restart recovery,
# position reconciliation or risk controls. Choose valid size/funds in Studio.
# GETTING STARTED
# 1. Open Data and download candles for an exchange, market, and symbol.
# 2. Press F5 inside a project: the XTester engine runs this file with Rscript over the
# project's candles, executing orders, fees and balances itself; this file only decides.
# R must be installed (https://cloud.r-project.org); the R pack adds jsonlite and the language server.
# 3. Add your decisions in on_bar. context$api places orders (buy, sell, place_order,
# close_position); context$indicators reads the engine's indicators (rsi, sma, ema,
# call("ADX", list(period = 14))); context$logger writes to the strategy log.
# Ask the AI assistant to explain this file.
create_strategy <- function() {
state <- new.env()
state$phase <- 0L
list(
on_init = function(context) {
context$logger$info(paste("UserStrategy initialized:", xtester_symbol_text(context$parameters$symbol_key)))
},
on_tick = function(context, price) {
},
on_bar = function(context, symbol_key, bar) {
if (state$phase == 0L && bar$close > bar$open) {
result <- context$api$buy("0.01")
state$phase <- if (result$success) 1L else 2L
if (!result$success) context$logger$info(result$error_message)
} else if (state$phase == 1L && bar$close < bar$open) {
result <- context$api$close_position()
state$phase <- 2L
if (!result$success) context$logger$info(result$error_message)
}
},
on_finish = function(context) {
}
)
}
main.pine
Pine subset interpreterDownloadOriginal EMA crossover strategy for the Pine subset interpreter. Source
//@version=6
// XTester's own Pine interpreter runs this script once per closed bar and
// the engine executes strategy.entry / strategy.exit / strategy.close orders,
// fees and balances. Plots and drawings are accepted and ignored.
strategy("UserStrategy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 10)
fast = ta.ema(close, input.int(9, "Fast EMA"))
slow = ta.ema(close, input.int(21, "Slow EMA"))
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
plot(fast, "Fast", color.new(color.blue, 0))
plot(slow, "Slow", color.new(color.orange, 0))XTester in action
See the chart, strategy testing and work with the AI assistant in action.
The embedded YouTube player connects when the page loads. Press play to watch the video over the page.
Music and license
“Signal to Noise” — Scott Buckley · CC BY 4.0.
Recording excerpt edited with fades, loudness normalization and mixing.
Your trading bot
Run your finished strategy in Launcher
Choose Paper for a virtual account or Live to trade on your own exchange account. XTester Studio can also build a standalone bot package with the required components.
Execution conditions and CopyTrader
Your own bot
From strategy to your own bot
Launcher runs a finished strategy in Paper and Live modes. In XTester Studio, you can build a bot package for distribution.
Add your own name and logo to distribute or sell the bot under your brand (white-label). Build your own robot product → On your own server, you can run the bot in Paper mode or on HyperLiquid Testnet. Mainnet trading is not available through this setup. Server setup →
CopyTrader is a separate service for subscribers to copy trades. See its website for connection terms.
More about CopyTrader ↗Explore Launcher →Paper and Live
In Paper mode, the bot trades on a virtual account. In Live mode, it uses API keys for your exchange account. The app runs checks before starting Live trading.
On your own server
Paper and Hyperliquid Testnet are available for remote execution. Mainnet is not available in this setup.
Under your own brand
Choose your own name and add a logo to distribute or sell the bot under your brand (white-label).
Questions & answers
Documentation →Do I need to know how to code?
You can start by describing an idea. The specification wizard helps define the rules, and the AI assistant helps write and fix the code. AI requires your provider key or a local model. If you write the code yourself, the editor has templates and hints.
What language are strategies written in?
Strategies can be written in C#, Python, JavaScript, TypeScript, Pine Script, Java, C++, Rust, Go and R. C# has the fullest support, including AI Lab. The other languages use experimental adapters. Available libraries and calculation results may differ.
What works locally and what needs the network?
The editor, projects, downloaded history, backtests and reports run on your computer. They do not require an account or exchange keys. You need the internet to download data, updates and language packs, and to use GitHub or cloud AI. You can connect a local model instead of a cloud provider.
How much does it cost?
XTester Studio is free, with no feature limits. Cloud AI is billed separately at your chosen provider's rates. You can use a local model instead.
Other questions
Can I bring over an existing strategy?
Yes. The conversion wizard accepts a file, folder, archive, text, link or GitHub repository. It creates a new project and describes what it changed and which features are unsupported. Conversion requires an AI model. Afterwards, compare entry and exit times and directions with a reference trade list. Check the financial result separately.
How compatible is Pine Script with TradingView?
XTester supports part of Pine Script v5/v6 and calculates trades with its own engine. Common indicator functions and trading commands are available. Plots, drawings and alerts are not executed; library imports and some other features are unsupported. Order execution, fees and slippage can differ from TradingView, so identical code does not guarantee identical results.
What else do I need to install for my language?
Everything needed for C#, JavaScript, TypeScript and Pine Script comes with XTester Studio. For Python, Java, Go and Rust, the app offers a language pack. Python can also use your own interpreter. C++ needs a system compiler, and R needs an R installation. XTester Studio offers downloads for additional components.
How is a backtest different from a robustness check?
A backtest shows how a strategy performed over the selected period. A robustness check repeats the calculation with different fees and slippage and over individual market phases. This helps you see how much the result depends on the conditions. Those phases come from the same history, so test the strategy on new data separately.
Can I connect an external AI agent?
Yes. Through MCP, a compatible client can access the project, data and test results. You must approve the connection in XTester Studio. You can allow read-only access; only one session at a time can make changes. More about MCP
Which exchanges are supported?
You can download history from the 20 centralized exchanges and 3 DEXs listed above, including Binance, Bybit, OKX and HyperLiquid. Spot and futures data are available. Instruments and history depth depend on the exchange.
Can I trade live from XTester?
Yes, through XTester Launcher, which comes with Studio. Open a finished strategy and choose Paper for a virtual account or Live for your exchange account with API keys. The app runs checks before starting Live trading. The Launcher window shows positions, orders and trades; notifications include Telegram. You remain responsible for trading decisions.
Where is my data stored?
Projects are stored on your disk. Telemetry requires your consent. A cloud AI provider processes the data you send under its own rules. If you do not want to use cloud AI, connect a local model.
What are the requirements?
64-bit Windows, macOS or Linux. The download page lists system requirements and files for each platform. Some languages need the additional tools listed above.
Latest articles
Loading articles…
XTester