Custom Indicators
Requires SuperAvailable on: Web
On this page
- Tour
- Write your first indicator
- Add a second plot
- Start from an official script
- Use it in a scan
- Sort results by it
- See its value in the results
- Draw it on a chart
- How a script asks to be drawn
- On your scan's result charts
- Update the scans that use a script
- Share a scan that uses one
- Ask the AI
- In the editor
- In the AI terminal
- Limits
- Tips
- Troubleshooting
- Related
A custom indicator is a study you write yourself, as a short script, when no built-in study computes what you want. You save it once, then filter on it in any scan and draw it on any chart, like RSI or a moving average.
This page covers the editor, your first script, and using a script in scans and on charts. The Custom Indicator Language page is the reference: every statement, the official scripts, the limits and what the language can't do yet.
Tour
Open Custom Indicators in the sidebar. It has two pages: Editor, where you write a script, and My Scripts, your library.
The script on the left, its check and its preview on the right.
- Script source (left): the code editor. It highlights the language and underlines each problem the compiler finds. Its bottom-right corner shows the check: "Compiles", or the first problem with its line and column. Click the problem to jump to it, or point at it to read all of them. Next to it, the counter shows the script's size against the 16,384-byte limit.
- Name and Script menu (top right): click the pencil to rename. Script holds New script, Save, Load script, Official scripts, Ask AI about this script and Delete. An amber dot on it means unsaved changes.
- Budget: how much of the cost and lookback limits the script and each plot use, measured with every input at its maximum. While the script doesn't compile, the panel shows the plots the compiler could measure and marks any plot that is over a limit.
- Inputs: the inputs your script declares. Values you try here aren't saved, but the preview draws with them. While the script has errors, you see the inputs that compiled or the ones from the last version that compiled, and a note says which. Values you typed stay, and the preview uses them once the script compiles.
- Reference: every function with its arguments and allowed lengths, a Guide of worked examples, and Names from other languages.
- Preview: the script on a chart of daily bars, for SPY until you pick another ticker.
- AI chat (under the editor): ask for a change and review it before it touches your script.
The Official tab holds the scripts from scanr. Copy one to make it yours.
My Scripts has three tabs. Custom lists the scripts you wrote or copied, Official the scripts from scanr, and Deleted the ones you can still restore. The count next to New script shows how many of your plan's scripts you've used.
Write your first indicator
This example measures how far the close has stretched from its average, in ATRs (average true range, the stock's typical daily range). A reading of 2 means the close sits two typical days' range above its average.
-
Click Editor under Custom Indicators. A new script opens with a starter that compiles:
-
Replace it with this script:
-
Watch the editor's bottom-right corner. It reads Compiles once the last
;is in. If it shows a problem, click it to jump to the line. -
Look at the Preview.
Stretchgets its own pane under the price chart. Type a ticker in the box to try another stock. -
Open Inputs and set
lengthto 50. The preview redraws. The script keeps its default of 20. -
Click the pencil next to My indicator and name the script, for example
ATR Stretch. -
Press Ctrl+S, or open Script and click Save. The first save is v1.
Not on mobile yet
Writing and saving scripts needs a larger screen. On a phone, the editor shows a saved script read-only.
input length = 20 (2..100) declares an input a scan or chart can change, from 2 to 100. def names a step. plot is what a scan compares and a chart draws. The if atr > 0 guard stops a halted stock, whose range is 0, from dividing by zero. The language page explains each statement.
Add a second plot
A script can have up to 8 plots, and a scan picks the one it compares. This version adds a true/false plot that marks the bars where the stretch passes a limit:
The step is called stretchValue, not stretch, because names ignore case: a def stretch and a plot Stretch would be one name used twice. On the preview, Overstretched puts a dot over each bar where it is true.
Save again and the editor saves v2. Your scans keep the version they were built with until you upgrade them.
Start from an official script
- Open My Scripts and click the Official tab.
- Open a script to read it. Official scripts are read-only.
- Click Save a copy in the editor, or Use as template in the row's menu on My Scripts. The copy is yours to edit, and the editor shows which script it started from.
Use it in a scan
You can add a custom indicator to a scan two ways:
- On a filter group, click +, then Custom indicator. The new row asks you to Choose an indicator.
- On any technical filter row, click the study name, then open the Custom tab of the study picker.
Then:
- Pick a script under Your indicators or Official.
- If the script has more than one plot, choose one under Plot.
- Set its inputs. Leave an input empty to use its default.
- Set the condition, as on any technical filter: a value, a range, another study or the price. A true/false plot reads is true or is false.
- Click Scan.
With the example script, Stretch set to greater than 2 finds stocks closing more than two ATRs above their 20-day average. The row also shows what the scan's custom indicators cost together against the per-scan budget, and names the one that takes most of it.
On the mobile app, a scan that uses a custom indicator runs as saved, and its row is read-only. You add and edit custom indicator filters on the web.
Sort results by it
A scan can rank its results by a custom indicator, whether or not a filter uses it. Click the gear beside Scan, go to Sort and open Field. The custom indicators sit at the end of the list: the ones this scan's filters use, then yours, then the official ones.
- Pick one. A pick from Custom indicators in this scan copies that filter's plot, inputs and timeframe. Any other pick starts daily, on the script's first plot and default inputs.
- Choose the plot, if the script has several, and click Inputs to change its inputs.
- Set Direction, then run the scan.
Results are ordered by each match's latest value of that plot, on the as-of date if the scan has one. A ticker with no value sorts last in both directions, and ties break on ticker.
The sort counts as one of the scan's custom indicators and adds to its cost, even when a filter uses the same script. When the scan's filters already use your plan's limit, the custom indicators in the list are disabled.
You choose this sort on the web. The mobile app's sort list can't offer it yet and shows nothing selected for a scan that has one.
See its value in the results
On the web, a scan with a custom indicator adds a column for it right after the symbol, named after the script. If the script has several plots, the name includes the plot. Each mix of script, version, plot, inputs, timeframe and session gets its own column, so two filters on the same settings share one. A script you only sort by gets a column too.
Each cell holds the plot's latest value, for the page you're viewing. A true/false plot reads True or False. A dash means the stock has no value yet, usually because it has too little history for the script's windows. If scanr couldn't read the values, point at the dash to see why. Your results still load.
The value skips a filter's bars-ago offset and modifiers, so it can differ from the number the filter compared. A scan with an as-of date hides the column, because scanr can only read the latest bar's value and today's number would sit beside a past date. Shared snapshots show no column either.
To hide a column, open the menu at the end of the header row and look under Custom indicators.
Draw it on a chart
- Open the chart settings.
- Under Custom indicators, click Add a custom indicator.
- Pick the script and the plot, set its inputs, and click Add.
A plot that is a price level, such as an average, draws over the candles. A script's other plots share one panel: add a MACD script's MACD and Signal plots and both lines draw in the same panel. A true/false plot puts a dot over each bar where it is true.
How a script asks to be drawn
A script can ask for more than those defaults with five display statements: style, pane, level, fill and barcolor. A MACD script can draw its histogram as columns colored by sign, add a level at 0 and shade between its two lines. A scan ignores these statements, so restyling a script never changes what it finds. See How a chart draws a script.
What you set on your chart wins over what the script asks for. Click the settings button on a plot's row, then use Draw:
- On a true/false plot, pick Shaded bands to shade each run of true bars.
- On a number plot, pick Over the candles or In its own panel.
Pick a color and the plot uses it, even if the script colors it by sign.
On your scan's result charts
A scan that filters on a custom indicator draws it on its result charts while Auto overlays is Smart or All. The line uses the chart's timeframe and sessions, so it can differ from the timeframe your filter reads.
Smart keeps the view short: two overlays and one lower panel, and your scripts fill them before any built-in study does. All draws every script your filters use, up to your plan's custom indicators per scan.
A script you only sort by does not draw, and neither does a deleted or switched-off one, or a row with a value outside its input's range. A chart preset you save from the results does not keep a filter's script, so add the script in Chart settings to keep it. See Show your scan on the chart.
Update the scans that use a script
Every save makes a new version, and a scan stays on the version it was built with until you upgrade it. To move one scan, click Upgrade to v3 in the note above its filters.
To move several, open the script in the editor. Under its name you see how many saved scans use it, for example Used by 5 scans (2 with alerts). When some sit on an older version, click Upgrade scans to v3. The dialog saves the scans whose filters carry over, one at a time, and lists the ones that need a look. Saving a scan starts its alerts again from the new version. See Versions and upgrading a scan.
Share a scan that uses one
Your scripts are private. When you share a scan that uses one, the share dialog warns Recipients can’t run this custom indicator and names it. Anyone who opens the link sees the other filters and these results. Click Create link anyway to go ahead.
When someone opens that scan in their editor, your script's filter is switched off so the rest of the scan runs, and a notice tells them. A sort on your script is removed the same way. Official scripts are never switched off. On the mobile app, opening a shared scan does this to every private script, even your own, because the app can't read your library yet. See Sharing a scan that uses a custom indicator.
Ask the AI
The AI can write a first draft, explain a script or fix one that doesn't compile. It checks every script it writes with the same compiler as the editor. The AI terminal is part of Super and Super Pro.
In the editor
- Type in Ask AI to change this script… under the editor, or press ⌘I (Ctrl+I on Windows). With an empty chat you can also pick Explain what this script does, Fix the errors in this script or Add an input for the length.
- The AI answers with a Proposed change: a diff of your script, marked Compiles or with its problems.
- Click Apply to put the change in the editor, or Discard. ⌘Z (Ctrl+Z) undoes an applied change.
- Save as usual. Nothing is saved until you do.
On an official script, Apply to a copy makes you an unsaved copy with the change in it. Each script keeps its own chat. Open in terminal moves it to the AI terminal.
In the AI terminal
Describe the indicator you want: "Write a custom indicator for the close's distance from its 50-day average, in percent." The terminal replies with a Custom indicator draft card that shows the script, its inputs and plots, its cost and whether it compiles. Click Open in editor to load it as a new, unsaved script.
The terminal can also work with the scripts you've saved, by name:
- "Explain my ATR Stretch script" reads the saved script and explains it.
- "Scan for stocks where my ATR Stretch is above 2" builds a scan that uses it.
- "Scan for stocks where my RSI of volume is below 30" runs the script on another series, if it has a series input. Your plan decides which series you can pick, as it does in the scanner.
- With Let the AI assistant make changes turned on in your account settings, it can offer to save a draft. It shows a card, "Save “ATR Stretch” as a new custom indicator?", and saves only when you click Save script.
Limits
The editor checks a script before it saves, and the scanner checks it again on every run.
Lookback and cost are measured at the top of every input's range. ATR and the other smoothed averages count 4× their length toward lookback, so ATR(high, low, close, length) with length up to 200 uses all 800 bars, with no room left for an offset or a nested window. The example caps length at 100 to leave that room. When a script is over budget, lower the top of the range, not the default.
Your plan's history limit applies too. On Super, a scan refuses a custom indicator that reads more than 400 daily bars back at the inputs the scan sets, the same limit built-in studies have. Super Pro has no plan limit. The error names the indicator and the number of bars it asked for.
The language page explains how lookback adds up and how to build windows longer than 200 bars.
Tips
- Start from an official script close to your idea. Each one teaches part of the language, from RELVOL (one line) to Squeeze (three plots).
- Keep input ranges as narrow as the idea needs. The range, not the default, sets the cost and lookback.
- Guard every division with
if … > 0 then … else 0. A halted stock has zero range and zero volume. - Count rows, not scripts. Two filter rows on one script's plots use two of your plan's per-scan custom indicators, and each plot on a chart uses one of its chart limit.
- Rename freely. Scans find a script by its id, so a rename never breaks one.

