thinkScript strategy workflow

thinkorswim Backtesting: Build and Review a Strategy

Backtesting on thinkorswim means applying a thinkScript strategy to historical chart bars and reviewing its simulated orders and report under stated assumptions.

Source review completed

Prompt brief

ThinkScript · one source file

Review in thinkorswim

Example request

Create a long-only thinkScript strategy that enters on a confirmed 20/50 EMA crossover, exits on the reverse crossover, exposes trade size as an input, and avoids repeated entries while already long.

Editable sourceFocused revisionsCheck in native editor

Direct answer

In thinkorswim desktop, add a thinkScript strategy to a chart, choose the symbol, aggregation, loaded history, and trade size, then right-click a strategy arrow and choose Show Report. Inspect the AddOrder price and timing rules. Record commission and slippage assumptions separately; do not assume the native report has deducted them.

What to know first

  • The chart aggregation, loaded history, session, and inputs define the test context.
  • Global strategy settings control entry behavior and default trade size; an AddOrder tradeSize argument overrides that size.
  • A parser-valid strategy can still contain look-ahead or logic errors.

Practical workflow

Follow the steps in order

  1. 01

    Write deterministic rules

    Define entries, exits, repeated-signal handling, position direction, and any session filter so another person could reproduce the same decisions from the same bars.

  2. 02

    Create a thinkScript strategy

    Represent the rules in one strategy source file. Add explicit inputs and use AddOrder only for the simulated entries and exits you intend to measure.

  3. 03

    Set the chart and strategy properties

    Set the symbol, aggregation, loaded history, session, default trade size, and repeated-entry settings. Inspect any size or fill-price override in the source. Keep a separate cost worksheet unless the calculation explicitly models costs.

  4. 04

    Review and challenge the report

    Right-click a strategy arrow and select Show Report. Inspect timestamps, quantities, prices, and P/L for individual orders. Derive additional risk measures separately and repeat the analysis on unseen dates and less favorable costs.

    Historical simulated performance is sensitive to data and assumptions. It does not demonstrate future profitability or executable live fills.

What a thinkorswim backtest measures

A thinkorswim strategy annotates historical bars with simulated orders. The strategy report summarizes the trades produced by that source on the current chart context. Changing the aggregation, date range, or strategy properties can change the trade sequence and reported outcome.

Preserve the code, inputs, chart settings, and a separate record of cost adjustments. The documented Global Settings controls do not establish that commission or slippage has been deducted from report P/L.

Checks that code generation cannot replace

Pineify can turn explicit rules into an editable strategy and revise the source. It does not run the native thinkorswim report or validate the broker data used by the platform.

Review bar offsets for future data, confirm the intended price is used for each condition, and test whether the first usable bar has enough history. Then compare a sample of simulated orders with the underlying bars.

  • Separate in-sample design dates from holdout dates.
  • Test costs and fill assumptions that are worse than the baseline.
  • Distinguish the number of suggested orders from completed round-trip trades; calculate drawdown from a defined equity series.

Next-bar prices and a cost example

AddOrder schedules a simulated order for the next bar; its default price is open[-1], the next bar open. That default execution-price reference is different from using future prices to decide whether to enter. Do not assume a signal at the current close fills at that close.

For a hypothetical 100-share trade, buying at 50 and selling at 51 gives $100 gross P/L. Assuming $0.02 adverse slippage per share on each side and $1 commission per order leaves $94: 100 - 4 - 2. This is arithmetic under stated assumptions, not a thinkorswim result or evidence of achievable fills.

Pineify thinkScript workflow

Turn the specification into editable thinkScript

Give the Coding Agent the formula, inputs, plots, alerts, and edge cases. It returns one editable study or strategy file and keeps focused revisions in the same code artifact.

Open the thinkScript agent

Sources and scope

Last verified:

Pineify provides information and code-generation assistance, not investment advice. Generated scripts, strategy reports, simulations, and historical examples cannot predict prices or guarantee returns. Review every script and test it in its target platform before relying on its output.

Frequently asked questions

Can you backtest on thinkorswim?

Yes. Add a thinkScript strategy to a chart and review its simulated orders and strategy report. The result depends on the source, chart data, inputs, and strategy properties.

What is the difference between a thinkorswim study and strategy?

A study calculates chart output such as plots or alerts. A strategy adds simulated orders so specified rules can be reviewed on historical chart data.

Does Pineify run the thinkorswim backtest?

No. Pineify generates or edits the thinkScript strategy source. You run the strategy and inspect its report inside thinkorswim.

Continue in the thinkScript coding workspace

Generate one editable thinkScript study or strategy, inspect the source, request focused changes, and complete the final check in thinkorswim.

Pineify generates source code. Review its syntax and chart behavior in thinkorswim before use.