Paperterminal Docs

Strategies and backtesting

Save private Pine source, test historical performance and run the built-in momentum strategy.

Open Strategies in the trading desk. Choose the bundled momentum strategy or New strategy, paste a Pine v5/v6 strategy, name it and save. Each account owns its source and backtest history; no leaderboard or protocol analytics exposes them. Source edits do not change an already-running bot.

Choose BTCUSDC or ETHUSDC, 1m/5m/1h/4h/1d, and 250–5,000 completed Hyperliquid spot candles. Results show marked equity return, realized PnL, open PnL, cash drawdown, win rate and recent fills. Initial bars warm up indicators. The bundled source starts trading January1,2025. The built-in model includes0.1% fees per side and$1 price slippage. Custom Pine assumptions come from its strategy() declaration. A profitable backtest is not proof of future or copied performance.

Private storage and API

Your strategies and backtests are private to your account. Other users cannot read them or reference them. Backtests retain the evaluated source/hash, market, timeframe and data range even if the saved strategy is later edited. Only the latest20 runs are listed, but older records remain stored.

  • GET /api/v1/strategies: own scripts and latest20 backtests; read scope.
  • POST /api/v1/strategies: name and source; optional id updates an owned strategy; trade scope.
  • POST /api/v1/strategies/backtest: name, source, optional owned id, symbol, interval, bars; trade scope. Runs are historical simulation, never live trades.
  • GET /api/v1/strategies/candles: symbol, interval, bars; read scope.

Use a signed-in browser session or an account-wide API key. Wallet-restricted keys cannot access account-wide scripts. See Scalar for request schemas. Backtests accept at most12,000 source characters and5,000 candles. One backtest per account runs at a time.

Pine compatibility and isolation

The exact bundled source uses our native momentum evaluator. Editing that source switches to the separate PineTS0.11.0 service. Its native Pine support is experimental, not TradingView's proprietary compiler. Imports and external request.* feeds are unsupported. Unsupported features produce errors, not fallback signals.

The isolated service executes source inside disposable non-root containers with no network, wallet data, database credentials or mounted volumes. Each job has a20-second CPU wall deadline and256MiB memory limit. No pasted script executes in a signing process. The runner is AGPL-3.0-only; its source is linked from the backtest results.

Live momentum bot

Only the reviewed built-in strategy can run live. In Strats → Bots, choose Momentum, a market and a risk preset (Careful, Balanced or Aggressive). The preset fills the allocation, leverage and loss limit; the sliders change them. Then start explicitly. Copy trading must be stopped and the account empty. It waits for a new completed4h candle after starting; it never catches up by entering an old historical signal. One long position at a time,20-bar breakout,200-bar SMA,positive20-bar momentum,3×ATR trailing stop,10-bar exit channel. Session bounds:100 trades/30days plus your loss limit.

Signals use Hyperliquid spot candles; live exits watch the existing Papertrade reference feed. Reference/venue settlement, leverage and fees can differ from backtests. Allocation risk is0.5% divided by the ATR fractional stop distance, capped at95% notional exposure and your maximum margin. Available USDC and venue minimums/OI still constrain admission; amounts are never increased merely to fit a minimum. A small allocation can produce no eligible orders. Live leverage does not increase the risk-sized notional target.

Use wallet commands with action:start and config.strategy:momentum for API automation. Existing config fields remain required (marketId,margin,leverage,maxCapital,maxLoss,holdSeconds,maxCycles,maxMinutes,fillTimeoutSeconds,reinvest). POST /wallets/{walletId}/commands requires trade scope and an Idempotency-Key. action:stop drains the bot as usual. Source pasted into the library cannot be supplied as executable worker code.

Consumed signal timestamps, stop levels and order identifiers persist in normal worker recovery state. Prepared identifiers are checkpointed before broadcast. Ambiguous outcomes block new submission; explicit rejected closes resume protection after a backoff. Hosted restart recovery still requires the existing unattended-signing grant.

Oracle catch-up bot (Cardboard)

The Cardboard oracle is the median of five Solana market-maker pools. It follows Binance and Coinbase by about 0.6 seconds. In Strats → Bots, choose Oracle catch-up with a managed Cardboard wallet, pick a market and a risk preset, and start. You do not need to type any value: the preset and the sliders set the margin, leverage and loss limit, and you can tap a dollar value to enter an exact amount. While it runs, the panel shows each reference's gap to the oracle against the entry marks.

  • The bot measures the normal price difference between each reference and the oracle for 30 seconds first.
  • It opens one position when Binance and Coinbase both lead the oracle by the minimum gap (default 3 bp), on the same side. One reference alone never opens a position.
  • It closes the position with the close rule you choose (under Advanced):
    • Catch-up (default) closes as soon as the oracle catches up to Binance and Coinbase, or when they reverse, or after 10 seconds. An optional profit target is off by default. It was the most stable rule in our tests.
    • Trail rides a trend: it closes when the oracle falls back 2 bp from its best point, at a 3 bp loss, or after 30 seconds. It won in a trending test and lost in a quiet one.
    • Fixed closes after a set time.
  • Take profit and stop loss of the margin apply to every rule.
  • Research mode (the checkbox under Stop after losing): the run does not stop on total losses, so it can collect many trades for tuning. Each trade still uses one margin and its own close rule, and the trade and time limits still apply. Up to trade limit × margin can be lost.

Every catch-up trade is saved to your account for tuning: both reference gaps at the signal, the oracle price, the entry and exit prices, how long each fill took, the best and final move, the PnL, the fees and the close reason. Only you can read your rows.

  • A refused open waits 5 seconds. The run stops at the trade limit, the runtime limit or the session loss limit.

A Cardboard fill uses the oracle about 1 second after the request, so much of the gap can close before the fill. Each close costs 0.5 bp of the order value, and a win pays 98% of the gain after a 0.2 bp deadband: a trade must move about 0.7 bp to break even. Leverage does not change that ratio; at 200× it is 1.4% of the margin. Holding longer does not fix this by itself: in our out-of-sample test a trailing exit lost. What matters most is fill speed: with fills about 1 second after the request the edge was small and positive; at 1.5 seconds every exit rule lost. That is an estimate from short samples, not a promise of profit. Use moderate leverage: at 1000× the bust price is 5 bp from entry. The operator can freeze an account or settle a position at a chosen price.

API: POST /api/v1/cardboard/wallets/{walletId}/bot/start with strategy: "catchup", gapBps (0.5-50), closeMode (trail, smart or hold), trailBps and stopBps (trail), closeGapBps and profitBps (smart), and the usual bot fields. holdSeconds (1-300) is the timeout of trail and smart, and the hold of hold.

Papertrade settlement and fast candles

POST /api/v1/strategies stores a new {name, source} strategy; include its id to update it. GET /api/v1/strategies lists your scripts and latest saved runs. All records are private to the authenticated account. Use an account-wide key with trade scope for writes/backtests and read scope for reads.

POST /api/v1/strategies/backtest accepts {name, source, id?, symbol, interval, bars, costModel, platformFeeBps}. Symbols: BTCUSDC or ETHUSDC (legacy USDT identifiers are accepted as aliases for USDC spot). Intervals: 1m, 5m, 1h, 4h, 1d. Bars: 250–5,000. costModel defaults to papertrade; pine uses source commission assumptions. SaaS platformFeeBps defaults to 100 (1% of positive settled profit); 0 is an explicit fee-free comparison, not a live fee waiver.

Papertrade mode records the current settlement curve, profit-fee rate, block and capture time with the run. It applies the existing integer settlement math, including the favorable-price deadband and market-specific profit haircut. This is a current-parameter scenario, not reconstruction of historical fee changes. PAPER incentives are not cash profit and are excluded.

For the built-in native momentum strategy, settled profit changes subsequent sizing and equity. For arbitrary Pine, an additional fixed-fill replay settles every closed long/short fill against the curve. That replay does not rerun equity-dependent Pine decisions or compound resized orders. Original Pine charts remain separately labelled. Liquidations, historical OI, queue delays, minimum order admissibility, and settlement liquidity are not simulated. A profitable replay is not evidence that those orders were executable.

Historical candles come from Hyperliquid USDC spot, not Papertrade execution fills. Historical 1-second candles are unavailable; collect live spot ticks separately for second-level research. OHLC bars do not establish the order of intrabar flips. Validate on separate out-of-sample windows and adverse latency/slippage assumptions before trusting fast-flip results. There is no promised profitable or accurate-flip strategy.

Research templates

The library includes independently written Pine v6 RSI/Bollinger reversion, EMA pullback, channel breakout, and Supertrend-flip templates. These support long and short research. Their Pine reference sizing is unleveraged; they are not certified profitable systems and cannot be activated as arbitrary live worker code.

A first separate high-leverage research sweep tested 3,024 combinations on BTC/ETH proxy candles (30 days at 1m, six hours at 1s). Some training settings exceeded 80% wins but none of those settings was profitable. Four train/validation-selected finalists all failed stressed validation profitability. This screening does not validate live execution or an 80–90% winning bot. Use independent forward data before deploying a strategy.

On this page