Skip to content
Back to App

Getting Started with the Playground

This guide walks you through running your first algorithmic backtest. By the end, you will have executed a strategy against real historical data and seen the results on an interactive chart.

Prerequisites

  • A TestMax account with an active Pro subscription
  • A modern web browser (Chrome, Firefox, Safari, or Edge)
  • No local Python installation required — strategies run on the server

Your first backtest

  1. Open the Algo Playground

    Navigate to the Playground page from the main sidebar. You will see the configuration panel on the left, a chart area in the center, and the output/code/trades panel at the bottom.

  2. Select an instrument

    Use the Instrument dropdown to pick a futures contract. For your first run, select NQ (Nasdaq 100 E-mini). Other available instruments include ES (S&P 500), GC (Gold), MNQ, MES, and EURUSD.

  3. Set the date range

    Choose a Start Date and End Date for the historical data. For a quick first test, pick a single day — for example, 2025-01-15 for both start and end. A day covers the whole calendar day (UTC), not just regular trading hours, so on NQ it holds roughly 23 hours of trading: about 1,380 bars at 1m.

    The note under End Date shows the last day with data for the selected instrument (“Data until …”), and the calendar only offers days inside the instrument’s data range. If you type a later date, the note turns red (“No data after …”), and a run for that range stops with “No data available for this instrument and date range”.

  4. Choose a timeframe

    Select a Timeframe from the dropdown:

    • 5s — Five-second bars. The finest option on NQ, ES, MNQ and MES, with the most bars and the slowest processing. Good for scalping strategies.
    • 1m — One-minute bars. Standard for most strategies.
    • 5m — Five-minute bars. Faster execution, fewer setups.
    • 15m — Fifteen-minute bars. Best for swing-style strategies over multiple days.

    The dropdown only lists timeframes the selected instrument’s stored data can build. 1s appears only on instruments stored at 1-second resolution, and no current public instrument is. On GC and the FX/CFD instruments (such as EURUSD) the finest available option is 1m. If you switch instruments and your current selection is no longer available, the picker snaps to the closest legal timeframe and shows a notice.

    For your first run, start with 1m (one-minute bars). This gives a manageable number of bars while still showing meaningful price action.

  5. Pick a strategy template

    From the Template dropdown, select SMA Crossover. This is a classic trend-following strategy that buys when a fast moving average crosses above a slow one, and sells when it crosses below.

    You will see the template’s configurable parameters appear below:

    • Fast Period — Default: 10. The number of bars for the fast moving average.
    • Slow Period — Default: 30. The number of bars for the slow moving average.

    Leave the defaults for now — they work well for a first run. A run processes every bar in the date range; the only way to cap the bar count is to edit MAX_BARS in a Custom Strategy’s code.

  6. Set the playback speed

    Use the Speed control to set how fast the backtest runs. Options range from 1x (slowest, about 2 bars per second, good for watching individual trades) to 100x. Throughput caps at about 100 bars per second, so 50x and 100x run at the same pace. For your first run, set it to 10x so you can watch the chart build up without waiting too long.

    You can change the speed while the backtest is running.

  7. Click “Run Backtest”

    Hit the Run Backtest button. Here is what happens:

    • The server creates a replay session for your selected instrument and date range.
    • Your Python strategy script begins executing on the server.
    • A WebSocket connection opens between your browser and the server.
    • Candles appear on the chart one by one as the strategy processes each bar.
    • Trade markers (green upward triangles for buys, red downward triangles for sells) appear when the strategy places orders.
    • The equity curve updates to reflect your running P&L.
    • The Output tab shows real-time log messages from the strategy.
  8. Watch the execution

    As the backtest runs, observe:

    • The chart — Candlesticks build from left to right. Watch for the moving average crossover points where trades are placed.
    • The output log — Shows [INFO] messages for strategy status, [TRADE] messages for each buy/sell, and progress updates.
    • The account bar — Displays running balance, equity, P&L, and trade count at the top.
    • The equity curve — The line chart below the main chart tracks your account balance over time.

    You can adjust the speed up or down during execution. Click Stop at any time to halt the backtest early.

  9. Review the results

    When the backtest completes (or you stop it), the output log shows the final summary:

    ────────────────────────────────────────────────────────────
    [DONE] Backtest Complete!
    [DONE] Final Balance: $50,245.00
    [DONE] Net P&L: +$245.00
    [DONE] Total Trades: 18
    [DONE] Win Rate: 55.6%

    Switch to the Trades tab at the bottom to see each individual trade with entry time, side (BUY/SELL), entry price, exit price, and P&L.

Understanding the output

The output log uses prefixed tags to categorize messages:

PrefixMeaningExample
[INFO]Status and configuration messages[INFO] Strategy: SMA Crossover (fast=10, slow=30)
[TRADE]Trade executions[TRADE] BUY @ 21503.25 | Fast MA: 21502.10 > Slow MA: 21500.85
[ERROR]Errors during execution[ERROR] Cleanup failed: name 'trade_count' is not defined
[DONE]Final results summary[DONE] Net P&L: +$245.00

Tips for your first runs

  • Start small. Use a single day and 1-minute bars before trying multi-day backtests at the 5s timeframe.
  • Try different speeds. Start at 10x to watch the strategy work, then rerun at 25x or 50x once you understand the pattern.
  • Experiment with parameters. After your first run, change the Fast Period to 5 and the Slow Period to 20, then rerun. Compare the results.
  • Check the Code tab. Select Custom Strategy and switch to the Code tab to see a full Python script with every section. This helps you understand the strategy structure before writing custom code. The pre-built templates run from the server, so for them the Code tab shows only a short note.
  • Use the Trades tab. The trade log shows every execution with precise prices. Look for patterns — are most losing trades happening at specific times or conditions?

Next steps

Now that you have run your first backtest, here is where to go next: