HimbitHimbit Markets Docs
Open Himbit Markets →

Strategy Tester

A Pine script that starts with strategy(…) places orders on the chart. The Strategy Tester shows what those orders would have earned on the bars loaded on the chart: the result, the trades one by one and the settings behind them. You need a signed-in account to run your own scripts (My indicators); the quickest start is the SMA Cross Strategy template.

Open and close

The Strategy Tester opens by itself when you add a strategy to the chart, with Add in My indicators or Add to chart in the editor. On a computer it sits in the dock under the chart, as a Strategy Tester tab next to the account tabs. On a phone it slides up as a sheet.

The name of the strategy is at the top left. With more than one strategy on the chart, pick the one you want from that menu.

× closes the panel. A Strategy Tester chip then stays on the chart with the strategy's net profit in %, for example +0.06%. Tap it to open the tester again on the tab you left.

Each order of the strategy is also drawn on the chart as an arrow with its name and size: green for buys, red for sells and grey for exits. They use the app's own colours and change with the theme when you switch between light and dark.

The line at the bottom reads, for example, Based on the 3,002 bars loaded · times in UTC · A backtest on past data, not investment advice.

The six tabs

  • Overview: Total P&L, Max equity drawdown, Total trades, Profitable trades (with the count, such as 45/134) and Profit factor, plus Open P&L while a position is open. Below them a chart of Cumulative P&L or Drawdown, with a Buy & hold box that adds a dashed buy-and-hold line. The mouse wheel zooms, dragging pans, Reset zoom goes back; hover or tap a point to read it, and click a trade's point to see that trade on the price chart.
  • Performance: a table with All, Long and Short columns: Initial capital, Open P&L, Net profit, Gross profit, Gross loss, Commission paid, Buy & hold return, Max equity run-up, Max equity drawdown and Max contracts held.
  • Trades analysis: Total trades, Total open trades, Winning trades, Losing trades, Percent profitable, Avg P&L, Avg winning trade, Avg losing trade, Ratio avg win / avg loss, the largest winning and losing trades (in money and in %) and the average number of bars in trades.
  • Risk/performance ratios: Sharpe ratio, Sortino ratio, Profit factor, Margin calls, Max margin used and Avg margin used.
  • List of trades: every trade with its entry and exit, Type, Date/Time, Signal, Price, Position size, Net P&L, Run-up, drawdown and Cumulative P&L. Sort Newest first or Oldest first, load more with Show more, and Copy as CSV to paste the list elsewhere. A tap on a trade shows it on the chart; on a phone the sheet closes so you can see it.
  • Properties: the settings the backtest used: Trading range, Backtesting range, Initial capital, Order size, Pyramiding, Commission, Slippage, the margin for long and short positions, Process orders on close, Risk-free rate, Symbol, Timeframe, Bars and Time zone (UTC). Notes from the engine about the script are listed under Notes.

How the backtest is calculated

  • Defaults: unless the script sets its own values in strategy(), Pine v6 starts with 100,000 capital and each order uses 100% of equity; Pine v5 starts with 1,000,000 and each order is 1 contract.
  • Bars: the backtest runs on the bars loaded on the chart, up to 5,000. Properties shows how many, for example 3,002 bars loaded (at most 5,000). Change the symbol or the timeframe and it runs again.
  • Fills: a market order fills at the next bar's open, or at the close with process_orders_on_close = true. Nothing fills on the bar that is still forming, unless the script turns on calc_on_every_tick.
  • Margin: an order that the account could not pay for is left out. The tester then says, for example, 3 orders were rejected for lack of margin — try lowering default_qty_value, on Overview and Properties.
  • Times are in UTC, as on crypto exchanges.

A backtest replays past data and is not investment advice: a strategy that did well on these bars can do badly on the next ones.