Search symbol...
HomeFeaturesMarketsPricingTrack RecordChangelogFAQBlogContactLoginGet Started
Scripting

Pine Script & ThinkScript Converter

Paste the source of a Pine Script indicator or strategy, or a thinkorswim ThinkScript study, into the AI Chat. ChartingLens converts it into a native indicator, draws it on your chart, and tells you what, if anything, had to be approximated.


What the Converter Does

Pine Script is the language behind most community indicators and strategies, written for TradingView. ThinkScript is the thinkorswim equivalent. ChartingLens turns either one into an indicator that runs natively on your chart: the same plots, colors, boxes, labels and tables, with the script's inputs still adjustable.

Conversion is rules first. A built-in converter compiles the script directly, with no AI model involved, and runs it on your chart's data before anything is drawn. Only when a script uses a construct the converter can't compile does the AI Assistant translate it instead, and that translation is also run against your chart, and corrected if it errors or draws nothing, before you see it.

Conversion uses no AI credits

Converting a script never spends your daily AI credits, whether it is Pine Script or ThinkScript and whether the rules converter or the assistant did the work. Script conversion is a Premium feature, included on Premium and Pro.


How to Convert a Script

1. Copy the full source

A paste is recognized as Pine Script by its //@version line or its indicator(), study() or strategy() declaration, and as ThinkScript by its def, plot and input statements.

2. Paste it into AI Chat

Open AI Chat from the right sidebar, paste the source and send it. No instructions are needed: a script paste always goes to the converter.

3. It draws on your chart

The indicator draws on the selected chart right away, and the reply card explains it, with a note on fidelity. If AI Settings has Chart changes set to Ask me first, click Add Indicator to Selected Chart on the card.

4. Tune, save and test

Use the gear in the indicator's legend to change its inputs, Save on the card (or the legend star) to keep it in your library, and Backtest Signals to test a strategy.

In a multi-chart layout, the card's Selected chart / All charts toggle decides where it goes. Once it is applied, the card's button changes to Remove from Chart.


What Converts

Pine Script versions

Pine Script v6, v5 and v4 convert, and so do older scripts that still use v2 and v3 spellings such as study(), security() and bare sma(). A paste that lost its indentation on the way is rebuilt before converting, and the reply says so.

ThinkScript studies

Most thinkorswim studies convert by rules: plots and their painting strategies, AddCloud, AssignPriceColor, AssignBackgroundColor, AddLabel (shown top-left), AddChartBubble, AddVerticalLine, Alert, AddOrder and higher aggregation periods. Where thinkorswim's formula differs from the standard one (ExpAverage and WildersAverage start from the first price), the converter writes out thinkorswim's version so the numbers match from the first bars. Moving off the platform? See our thinkorswim alternatives roundup.


What Gets Approximated, and How You Find Out

Every conversion reply carries a note. A clean rules conversion says every construct was supported and nothing was approximated. Otherwise the note names what changed:


Backtesting Converted Strategies

Every conversion card has a Backtest Signals button, and an applied script with trade signals gets a backtest icon in its legend, so you can re-run it after a page refresh. The backtest trades the script's own orders bar by bar: market orders fill at the next bar's open, stop and limit entries when price reaches them, and a protective stop is taken before a target when one bar touches both. Markers are not guessed at as trades, and a script with no strategy orders gets a plain message that there is nothing to backtest.

If a script paints signals late or deletes them (repainting), the backtest re-runs it on the history as it stood at each bar and trades each signal where it first appeared. It shares its engine with the AI Strategy Backtester; see also how to backtest a trading strategy.


After Conversion


Use Cases

Keep the indicators you rely on

Paste the community scripts you use and keep their logic, inputs and look instead of rebuilding your setup.

Bring your thinkorswim studies

ThinkScript studies and strategies convert by rules, with thinkorswim's own moving-average formulas so the values agree.

Test a published strategy

Convert a strategy() script and click Backtest Signals to see how its orders would have filled on any symbol and timeframe you load.

Screen the market with a script

Save the converted indicator, then scan NASDAQ + NYSE, an international market or your watchlists for its signals in the My Script tab.


Free vs Premium vs Pro

FeatureFree ($0)Premium ($14.99/mo)Pro ($29.99/mo)
Pine Script conversion (paste into AI Chat)Not includedIncludedIncluded
ThinkScript conversionNot includedIncludedIncluded
AI credits used per conversionNot applicableNoneNone
Save to your indicator libraryNot includedIncludedIncluded
Modify with AI (legend pencil)Not includedIncludedIncluded
Backtest Signals on converted strategiesNot includedIncludedIncluded
Signal alerts from the legend bellNot includedIncludedIncluded
My Script scans with a converted indicatorNot includedIncludedIncluded
Indicators per chart3UnlimitedUnlimited

Frequently Asked Questions

Does converting a Pine Script cost AI credits?

No. Converting a pasted Pine Script or ThinkScript study uses none of your daily AI credits, even when the assistant translates part of it. Conversion is included on Premium and Pro.

Which Pine Script versions does the converter accept?

Pine Script v6, v5 and v4, plus older scripts that still use v2 and v3 spellings such as study(), security() and bare sma().

Can I backtest a converted Pine Script strategy?

Yes. Click Backtest Signals on the conversion card, or the backtest icon in the legend. The backtest trades the script's own strategy.entry, strategy.exit and strategy.close orders, filled bar by bar. Pyramiding is not simulated.

What happens when part of a script can't be converted exactly?

The reply tells you. Every conversion includes a note saying either that nothing was approximated, or exactly what was approximated or returns na, such as footprint data or a reconstructed library.

Can it convert thinkorswim studies like TTM Squeeze?

Most ThinkScript studies convert by rules with no AI involved. TTM Squeeze and other proprietary thinkorswim studies have no published formula, so the assistant translates them instead and says so. Check the values if exact numbers matter.

Is Pine Script conversion available on the Free plan?

No. On Free, pasting a script shows an upgrade message instead. Premium ($14.99/mo) and Pro ($29.99/mo) include Pine Script and ThinkScript conversion, the indicator library and backtesting converted strategies.

Bring your scripts with you

Start free and chart every market, then move to Premium when you want your Pine Script and ThinkScript code running on ChartingLens.

Start Charting Free All Features