custom volatility-trend study

Supertrend Indicator for thinkorswim

Supertrend is a volatility-band state indicator built from price and an average true range calculation. Implementations can disagree on smoothing, band carry-forward, and reversal rules.

Source review completed

Prompt brief

ThinkScript · one source file

Review in thinkorswim

Example request

Create a thinkorswim Supertrend upper study with hl2 as the basis, configurable ATR length and multiplier, Wilder smoothing, documented final-band carry rules, colored state line, and completed-bar transition alerts.

Editable sourceFocused revisionsNative editor check

Direct answer

A reviewable thinkorswim Supertrend study needs a stated price basis, ATR length, ATR smoothing method, multiplier, final-band rules, and state transition condition. thinkScript provides true-range and moving-average building blocks, but the exact Supertrend formula should be written down rather than inferred from the name.

What to know first

  • ATR method and multiplier control the band distance.
  • Final bands usually carry forward under stated conditions rather than equal raw bands on every bar.
  • The first valid state and reversal-bar rule must be deterministic.

Reference points

Keep the calculation explicit

Price basis
The stated price series used to center the raw upper and lower bands.
ATR
A smoothed true-range series with an explicit length and average type.
Final bands
Stateful bands that follow the selected carry-forward formula.
Trend state
A deterministic selection of the active band based on current and prior values.

Why two Supertrend scripts can disagree

Implementations may use different price bases, Wilder or another ATR smoothing method, distinct initialization, or different comparisons on an equal-value bar. Each choice can move a reversal by one or more bars.

Preserve these choices as inputs or comments, then compare the resulting line and state across a known sample before adding signals.

Separate the state from a trade rule

A color change can mark the indicator’s trend-state transition. It does not define position size, entry timing, exits, or risk. Add those only in a separately specified strategy.

Pineify can generate the study and later convert explicit transitions into simulated strategy orders. Test the study first so strategy errors are not confused with indicator errors.

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 thinkorswim before relying on its output.

Frequently asked questions

Is Supertrend built into thinkorswim?

The official library provides ATR and true-range building blocks. A Supertrend formula can be implemented as a custom thinkScript study, but its variant must be specified.

What settings define Supertrend?

At minimum, define the price basis, ATR length, ATR smoothing, multiplier, final-band carry rule, initialization, and state reversal condition.

Can Pineify make Supertrend alerts?

Yes. Specify whether the alert fires on the first state change, on a completed bar, and how often it may repeat. Verify the state line before enabling the alert.

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. thinkorswim remains the platform authority for parsing and chart behavior.