Skip to content
Back to App

Pine Script

TestMax can run custom TradingView Pine Script (v5 and v6) directly on your replay charts. Write or paste an indicator or strategy, apply it to the chart, and watch it calculate bar-by-bar as the replay streams — the same scripts you use on TradingView, running against TestMax historical data.

What you can do

  • Bring your TradingView scripts — Paste an existing Pine v5 or v6 indicator or strategy and apply it to a replay chart. See Supported Features for exactly which parts of Pine are covered.
  • Plot indicators live during replay — Overlays draw on the price pane, oscillators like RSI or MACD get their own sub-pane, and everything updates in real time as candles stream — including the still-forming candle.
  • Run strategies with a deterministic backtest modelstrategy() scripts place simulated orders using TradingView’s default fill assumptions, with a Strategy Tester panel showing P&L, win rate, drawdown, an equity curve, and a trade log.
  • Edit with a real code editor — The built-in editor has Pine syntax highlighting and autocompletion for roughly 55 common functions, plus an error console that jumps to the offending line.
  • Save and reuse — Save up to 50 scripts to your account. Applied indicators and their input values persist per symbol and restore when you reload. Import and export scripts as .pine files from the editor sidebar — files up to 30 MB can be stored and synced, though scripts over 100 KB are download-only.

Indicators vs strategies

Pine Script has two kinds of scripts, and TestMax supports both. The kind is detected automatically from the declaration statement and shown as a badge in the editor.

IndicatorStrategy
Declarationindicator()strategy()
What it doesCalculates and plots valuesEverything an indicator does, plus places simulated orders
On the chartLines, markers, horizontal levels, sub-panesPlots plus entry/exit trade markers
Extra UIInputs dialog, legend controlsInputs dialog, legend controls, and the Strategy Tester tab

If you just want to see a moving average, VWAP, or a custom oscillator on your replay chart, write an indicator. If you want to test entry and exit rules with simulated fills and P&L, write a strategy — see Strategies for the full order model.

Runs in your browser

Your scripts execute entirely client-side, in a Web Worker inside your browser:

  • No server execution — Saved scripts are stored on the server so they follow you across devices, but they are never executed there. All compilation and bar-by-bar calculation happens on your machine.
  • No added latency — Indicator values update as fast as candles arrive, with no network round trip per bar.
  • The chart stays responsive — Because scripts run in a Web Worker, a heavy calculation cannot freeze the chart UI. Runs over chart history are capped at 30 seconds; a script that exceeds the cap halts with a timeout error instead of hanging the page.

How it relates to the Algo Playground

TestMax has two ways to run trading logic in code. They are separate features that serve different purposes:

Pine ScriptAlgo Playground
LanguagePine v5/v6Python
Where it runsIn your browser (Web Worker)On the TestMax server
Where you use itInside a replay session, on the chart you are already tradingIts own dedicated page with a configuration panel
Best forCharting custom indicators and quick strategy checks alongside manual tradingFull backtests over a date range using the TopStep-compatible API
Fill modelDeterministic TradingView-default simulationOrders placed through the replay order engine

If you are porting a TradingView script or want indicators on the chart while you trade a replay, use Pine Script. If you are building a Python algorithm you eventually want to run against the live TopStep API, use the Algo Playground.

Next steps