ITMScript
Your first study
Paste an RSI study into the chart editor, change an input, add it to the chart, then meet an error and fix it.
This page walks one study from paste to chart. You need a chart open and a plan that includes Custom study. The Indicators guide says where it is available.
Open the editor
Open Indicators in the chart header. Open Custom study. A script editor appears with three buttons: Validate, Format and Add to chart.
Paste the study
Paste this RSI study into the editor.
//@itmscript 2
// RSI with its bands, and the band drawn as a filled zone.
study("RSI", overlay=false)
len = input.int(14, "Length", min=2, max=500, step=1, group="Settings")
src = input.source(close, "Source", group="Settings")
r = ta.rsi(src, len)
plot(r, "RSI", color=color.purple, width=2, style=line)
top = plot(70, "Overbought", color=color.gray, width=1, style=line)
bottom = plot(30, "Oversold", color=color.gray, width=1, style=line)
fill(top, bottom, color=color.new(color.purple, 92))
hline(50, "Midline", color=color.gray, style=dotted)The study line names the study and puts it in its own pane. Each input line adds a setting a reader can change. ta.rsi does the calculation. plot, fill and hline draw the result.
Change an input
Select Validate. The editor reports a summary of what the study draws. The study's inputs appear below the editor. Set Length to 21 and the line follows the longer window. Every operator you use is described in the operator reference. Look up ta.rsi there to see its parameters and warm-up.
Add it to the chart
Select Add to chart. RSI appears in its own pane and in the Active indicators legend. Open its settings from the legend to change Length later.
Read an error
Mistakes are refused with a message that names the fix. Replace the editor's text with this short study. It has a typo in the operator name.
//@itmscript 2
study("Average", overlay=true)
avg = ta.smaa(close, 20)
plot(avg, "Average", color=color.blue)Select Validate. The editor puts the caret on the mistake and says:
Unknown name: ta.smaa. Did you mean ta.sma, ta.ema or ta.hma?The editor shows the line and column beside it. Take the first suggestion and write ta.sma.
//@itmscript 2
study("Average", overlay=true)
avg = ta.sma(close, 20)
plot(avg, "Average", color=color.blue)Select Validate again. The study passes, and Add to chart draws the average over the price.