thinkorswim programming language

thinkScript

thinkScript is the built-in programming language for thinkorswim. You write studies and strategies in the thinkScript Editor, and the platform renders plots, labels, alerts, and simulated orders on the chart.

HelloWorldStudythinkScript
input length = 20;

def avg = Average(close, length);
def isAbove = close > avg;

plot SMA = avg;
plot Signal = if isAbove then close else Double.NaN;

SMA.SetDefaultColor(Color.CYAN);
Signal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Signal.SetDefaultColor(Color.GREEN);

AddLabel(yes, if isAbove then "Above SMA" else "Below SMA",
    if isAbove then Color.GREEN else Color.RED);
inputs
plots
labels
Platform
thinkorswim desktop Editor
Output types
Studies, strategies, watchlist columns
Editor
Built-in thinkScript Editor

Direct answer

What thinkScript is and what it builds

thinkScript is a domain-specific language embedded in thinkorswim. You use it to create custom chart studies, backtesting strategies, watchlist columns, and conditional alerts. The language provides built-in access to price data (open, high, low, close, volume), technical analysis functions, and visual output controls.

A study calculates values and plots them on the chart. A strategy does the same and adds simulated orders with AddOrder so you can review a backtest report. Both are single-file scripts written in the desktop thinkScript Editor. The example above marks every bar above its average, not just the first crossover. No chart execution is claimed here.

01

Open the Editor

In thinkorswim, go to Charts, click Studies, select Edit Studies, then click Create to open the thinkScript Editor with a default plot. For AddOrder scripts, use the Strategies tab.

02

Write or paste source

Replace the default line with your study or strategy. Use def for variables, input for parameters, plot for visual output, and AddOrder for simulated strategies.

03

Parse and add to chart

Let the Editor check the syntax. Resolve any messages, save the study, and add it to a chart to inspect the plots, labels, and strategy behavior.

Language building blocks

Core thinkScript concepts

ConceptKeyword or functionWhat it does
VariabledefStores a calculated value for reuse in the script.
Input parameterinputExposes a configurable value in the study settings.
Visual outputplotDraws a line, point, or histogram on the chart.
Historical offsetclose[1]References the value from a previous bar.
Chart labelAddLabelAdds text to the chart with a condition and color.
Simulated orderAddOrderAdds a backtest order when a condition is true.
Painting styleSetPaintingStrategyChanges how a plot is drawn on the chart.
ColorColor constantsSets plot, label, and background colors.

Frequently asked questions

What is thinkScript?

thinkScript is the built-in programming language for the thinkorswim platform. You write studies and strategies in the thinkScript Editor, and thinkorswim parses the source and renders plots, labels, alerts, and simulated strategy orders on the chart.

Is thinkScript the same as Pine Script?

No. Pine Script is the language used on TradingView. thinkScript is the language used in thinkorswim. They share some concepts like plots, inputs, and historical offsets, but the syntax, function names, and platform behavior differ.

How do I open the thinkScript Editor in thinkorswim?

Open the Charts tab, click Studies in the upper right, select Edit Studies, then click Create. The Editor window opens with a default plot Data = close line that you replace with your own source.

Do thinkScript chart strategies place live orders?

No. AddOrder in a thinkScript strategy adds simulated orders to the chart for backtesting. thinkorswim does not send those orders to a brokerage account. Review the strategy report and test assumptions before relying on results.

Where is the official thinkScript documentation?

The thinkorswim Learning Center hosts the thinkScript tutorials, function reference, constants, declarations, and reserved words. Use the entry for the specific function and the platform context you need.

Can Pineify write thinkScript for me?

Yes. The Pineify thinkorswim AI Coding Agent can draft editable single-file thinkScript studies and strategies from plain English. It does not compile or execute them in thinkorswim. You review the source in Pineify, then paste it into the thinkScript Editor and test it on a chart.

Write thinkScript without memorizing the syntax

Describe the study or strategy you need in plain English. The Pineify thinkorswim AI Coding Agent can draft an editable thinkScript file. Review the source, then paste it into the thinkScript Editor and test it on a chart.

Open the thinkScript AI agent

This page is for educational and informational purposes. It does not provide investment advice, predict future prices, or guarantee trading results.