Skip to main content
On this page

How to Run Pine Script in TradingView (Step-by-Step)

· 5 min read
Pineify Team
Pine Script and AI trading workflow research team

Run Pine Script by opening TradingView's Pine Editor, creating or opening a script, saving it, and selecting Add to chart. Compilation checks the code; the chart shows its output. An indicator, a strategy backtest, and a live broker order are different things.

Open the editor and create an indicator​

Follow these five steps to run your first Pine v6 script:

  1. Sign in and open Supercharts on the TradingView web or desktop application.
  2. Click the Pine button on the right toolbar (older layouts and tutorials may show a bottom tab).
  3. Open the script menu at the top of the editor and choose Create new → Indicator. TradingView's Pine Editor guide documents the current interface.
  4. Replace the starter source with this complete example:
//@version=6
indicator("My First Script", overlay=true)
plot(close, title="Close", color=color.blue)
  1. Save the script under a recognizable name, then select Add to chart.

If Save and use more scripts appears as soon as you choose a new indicator, check the TradingView Basic saved-script limit and how to keep your existing code.

The version annotation selects Pine v6. indicator() declares the script type and places its output over the price chart. plot() draws each bar's close. This example is a display exercise, not a trading signal. After editing an existing chart instance, use the editor's update action and check the chart's script title. Saving source, updating a chart instance, and publishing a script are separate actions.

Verify the result before adding complexity​

Look for the blue close line and the script's name in the chart legend. Compare the value in the Data Window with the selected bar's close. Change the symbol or timeframe and confirm the series recalculates. If the line overlaps candles, temporarily hide the main price series or adjust the script's style to see it clearly.

The historical calculation proceeds bar by bar. On an open realtime bar, indicators normally recalculate as data updates, so the current close can change before the bar closes. Strategies normally calculate at bar close unless their settings change that behavior. See the execution model.

The Best Pine Script Generator

Diagnose the right kind of failure​

SymptomCheck
Compilation errorRead the reported message and nearby lines; confirm spelling, types, indentation, and version compatibility
Compiles but has no visible lineCheck visibility, scale, pane placement, and whether values are na
Runtime error after addingInspect history references, array indices, and calculation limits (such as RE10110 on Basic's 0.5-second limit)
Chart still shows old behaviorConfirm the intended saved script and chart instance were updated
No simulated tradesConfirm it is a strategy with entry conditions that actually occur

A script can display drawings, tables, or shapes without a plot() call. Omitting the version annotation makes Pine assume version 1; it does not universally cause a syntax error, but modern code will generally require its intended version. Script structure explains the declaration requirements.

Choose the next step by script type​

An indicator calculates values, displays information, and can expose alert conditions. A strategy uses simulated orders and reports results in Strategy Tester. Historical results depend on data, fill assumptions, costs, and the rules you specified; compiling successfully does not validate their profitability.

To receive notifications, create an alert in TradingView using the script's supported conditions. Adding alert code does not itself create a running alert, and free Basic accounts include price alerts rather than technical indicator alerts. See TradingView's free plan limits for 2026 for current alert and indicator caps. A strategy also does not directly place live orders merely because it is attached to a chart.

Saved personal source is separate from published source. Public, private, open-source, protected, and invite-only publication choices have different visibility and access rules. Check permissions before copying or redistributing another author's script. Continue with the Pine Script tutorial when you are ready to add inputs and calculations.

Frequently asked questions​

Which Pine version should a new example use?

Use the current v6 documentation for new work. Existing older scripts may still run, but migration requires checking the relevant language changes.

Why can't I save a second Pine script on TradingView?

TradingView's free Basic plan allows one saved personal Pine script. Back up your code locally before replacing the saved slot, or upgrade to Essential for unlimited saved scripts.

Does running a strategy trade my account?

No. Strategy Tester simulates orders. Broker execution requires a separate supported workflow and appropriate account controls.

Must I publish a script to use it?

No. Save your personal script and add it to your own chart. Publishing is a separate sharing action.