Your first script
Run the EMA Cross example, change one setting, and save it. It takes about two minutes.
- Open the Pine Editor tab in the bottom dock.
- Press Open ▾, and under Examples choose EMA Cross.
- Press Add to chart (Ctrl Enter). Two moving averages and buy and sell markers appear. The button now reads Update on chart: edit the script and press it again to refresh the same indicator.
- Click the gear on the indicator and change Fast length. The chart redraws.
- Press Save (Ctrl S). The script is now in Open ▾ → Saved and in the Indicators list under My scripts.
The indicators on your chart are kept when you close the app and come back when it starts. See Saving and restoring.
What the script says
//@version=5
indicator("EMA Cross", overlay = true)
fastLen = input.int(9, "Fast length", minval = 1)
slowLen = input.int(21, "Slow length", minval = 2)
fast = ta.ema(close, fastLen)
slow = ta.ema(close, slowLen)
plot(fast, "Fast", color.blue, 2)
plot(slow, "Slow", color.orange, 2)
plotshape(ta.crossover(fast, slow), "Buy", shape.triangleup, location.belowbar, color.green)
//@version=5says which language version the script is written for.indicator(..., overlay = true)names the indicator and puts it on the price chart. Withoutoverlayit gets a pane of its own.input.int(...)makes a setting. It shows up in the gear with the title you give it.ta.ema(close, fastLen)is a moving average of the close. The script runs once per bar, sofastis a different number on every bar.plot(...)draws a series.plotshape(...)draws a marker on the bars where its condition is true.
Starting from nothing
Press New for an empty script, or paste one from elsewhere. Type a name and press Ctrl Space for the list of functions with their parameters. If a script has unsaved changes, the editor asks before it lets you open another.