Skip to content
TradequixDocsOpen the terminal
OverviewStart here, search, progress
  • Introduction
  • Quickstart
  • How a script runs
  • Types and qualifiers
  • Operators, conditionals and loops
  • Functions and methods
  • Objects and enums
  • Arrays, matrices and maps
  • Strings and colours
  • Time and sessions
  • Bar states
  • Plotting
  • Inputs
  • Technical analysis
  • Drawings and tables
  • Multiple timeframes
  • Strategies
  • Alerts in scripts
  • Repainting
  • The Pine editor
  • Indicator settings
  • Coming from TradingView
  • The data
  • Publish and sell
  • Catalogue and community
  • Your dashboard and earnings
  • Errors and debugging
  • Limits
  • Coverage
  • Built-in catalogue
  • Cookbook
  • Write Pine with AI
  • FAQ
  • Glossary
  • Cheat sheet
  • Function reference
  • Will it run here?
  • Error index

Start

Quickstart

Write, run and save your first indicator, then turn it into something you would actually trade with.

View as MarkdownOpen in ClaudeOpen in ChatGPT

This page builds one script in four small steps. Run each step to see what changed.

1. The smallest script that draws#

Every script starts with a version line and a declaration. indicator() says this is an indicator; overlay = true puts it on the price chart instead of in its own pane.

RunnableMy first script
1//@version=62indicator("My first script", overlay = true)3plot(ta.sma(close, 20), "SMA 20", color = color.orange)

close is the closing price of each bar. ta.sma(close, 20) averages the last 20 closes. plot() draws the result as a line.

2. Make the length adjustable#

Hard-coded numbers become inputs. Each input.* call adds a field to the indicator's settings, so you can change it without editing code.

RunnableAdjustable average
1//@version=62indicator("Adjustable average", overlay = true)3length = input.int(20, "Length", minval = 1)4src = input.source(close, "Source")5plot(ta.sma(src, length), "SMA", color = color.orange, linewidth = 2)

3. Mark the crosses#

Signals are conditions. ta.crossover(a, b) is true on the bar where a moves above b. plotshape draws a marker on those bars.

RunnableCross markers
1//@version=62indicator("Cross markers", overlay = true)3fast = ta.ema(close, 9)4slow = ta.ema(close, 21)5plot(fast, "Fast", color = color.teal)6plot(slow, "Slow", color = color.red)7plotshape(ta.crossover(fast, slow), "Bull cross", style = shape.triangleup, location = location.belowbar, color = color.teal, size = size.small)8plotshape(ta.crossunder(fast, slow), "Bear cross", style = shape.triangledown, location = location.abovebar, color = color.red, size = size.small)

Note

plotshape draws only where its series is true or a non-zero number. A condition is the right thing to pass it. See Plotting for why plotshape(ta.pivothigh(...)) behaves the way it does.

4. A separate pane#

An oscillator lives in its own pane. Drop overlay = true (it defaults to false) and add reference lines with hline.

RunnableRSI with zones
1//@version=62indicator("RSI with zones")3r = ta.rsi(close, 14)4plot(r, "RSI", color = color.purple, linewidth = 2)5hline(70, "Overbought", color = color.red)6hline(30, "Oversold", color = color.teal)

Save it, then use it#

In the terminal's editor:

  • Add to chart (Ctrl Enter) runs the script on the chart you are looking at.
  • Save (Ctrl S) stores it in your account, so it is there next session.
  • The indicator's settings (the gear in its legend) show the inputs from step 2.
  • Publish shares it. See Publish and sell.

Next, read How a script runs. It explains close[1], var and na, which is where most first scripts go wrong.

PreviousIntroductionNext How a script runs

On this page

  • 1. The smallest script that draws
  • 2. Make the length adjustable
  • 3. Mark the crosses
  • 4. A separate pane
  • Save it, then use it

Use with AI

View as MarkdownOpen in ClaudeOpen in ChatGPT