FINTERM · docsOpen terminal
Backtester

Strategy backtester

Bar-by-bar JS strategy engine in the same Web Worker sandbox as indicators.

The Backtester window loads OHLCV from any Binance symbol + interval, then runs your strategy function against each bar in sequence. Returns: trades + equity curve + P&L + max drawdown + win rate + buy-and-hold baseline.

Strategy signature

// Called once per bar. Return a signal or null.
function strategy(bars, ctx) {
  // bars   = full bar history up to and including the current bar
  // ctx.i  = current bar index
  // ctx.sma(n) / ctx.ema(n) — helpers, returns most recent value or null

  return /* 'BUY' | 'SELL' | null */;
}

Default example — SMA crossover

const fast = ctx.sma(10);
const slow = ctx.sma(30);
if (fast === null || slow === null) return null;
if (fast > slow * 1.001) return 'BUY';
if (fast < slow * 0.999) return 'SELL';
return null;

Engine semantics

  • Starting equity: 1000 units of quote currency.
  • BUY converts equity to position at the bar's close. SELL closes the position at the close.
  • No slippage, no fees modelled. Take the P&L as 'best case' and add your venue's fee schedule mentally.
  • BUY when already long is a no-op; SELL when flat is a no-op.
infoSame Web Worker sandbox as indicators — same 1-second per-call timeout, same DOM-free environment. If your indicator code uses ctx.sma / ctx.ema you can drop it in here directly.