User indicator editor: write, run and show your own indicators
The "Custom indicators" dialog lets you write an indicator script, run it on the real bars of the current chart and save it. Saved scripts join the Indicators panel under "My scripts", where they are switched on and off like the built-in ones.
Senzoukria · Documentation · Updated September 2026
Where to find it
- Where
- Replay chart → "Script" chip (tooltip "Write your own indicator (runs sandboxed)"); Scripting page → "Show on the chart" toggle
- Storage
- localStorage key orderflow.userIndicators.v1; visibility per chart in the Indicators settings store
- Run scope
- Up to 600 most recent bars, real chart data, 2 s sandbox budget
- Cadence on chart
- At most one run in flight per script and at least 400 ms between two runs
What it does
The dialog is titled "Custom indicators". A list on the left shows each saved script with its draw target; "+ New indicator" creates one named "My indicator" with the default script (a 20-period SMA) and two parameters, Period (20, from 1 to 500) and Color (#7ed321). The right side holds the name field (48 characters maximum), the draw target selector and the same code editor as the Scripting page, with line numbers and Tab indentation.
The important button is "▶ Run on current chart". It executes the script in the sandbox on the actual bars of the chart, at most 600, and reports either "✓ N outputs in X ms — on N bars" or the error with its line number shown first. A Console block lists what the script printed with log() / console.log() (JavaScript) or print() (Python); when nothing was printed, a hint explains which function to use. Escape closes the dialog.
Settings
| Control | Default | What it changes |
|---|---|---|
| Indicator name | My indicator | Label shown in the list, in the Indicators panel and on tables/panels; up to 48 characters |
| Draw target | On the chart | "On the chart" draws over price; "Own pane" allocates a dedicated pane below the chart |
| Period parameter | 20 (min 1, max 500, step 1) | Passed to the script as params.period; adjustable later from the Indicators panel |
| Color parameter | #7ed321 | Passed as params.color |
| Run on current chart | — | Runs the script on up to 600 real bars and shows outputs, timing, logs or the error line |
| Save | — | Persists the script; unsaved edits are lost when the dialog closes |
| Delete | — | Removes the script and selects the next one |
Showing a script on the chart
Saving a script does not draw it. On the Scripting page, the "Show on the chart" toggle explains: "The indicator is drawn on the chart and joins the Indicators panel, in the "My scripts" group — switch it on and off from there like any other." Saving a new indicator from the Scripting page switches it on automatically. In the Indicators panel each script shows "chart overlay" or "own pane" next to its name; when the script fails, that spot shows the error instead.
On the chart, user scripts run in a worker with their own loop: at most one execution in flight per script and a 400 ms floor between two runs, so a slow script delays only its own drawing and never freezes the chart. Results are discarded when the instrument or timeframe changes, never when bars are merely republished. Parameter values set in the Indicators panel override the defaults declared in the script, and every declared key always receives a value.
Errors reported per script
| Code | Meaning | What to do |
|---|---|---|
| threw | compute threw or the sandbox interrupted it (2 s budget); the message and line are shown | Fix the line quoted; the previous drawing is removed so a stale curve cannot pass for a working one |
| shape | An output has a shape the renderer does not know | Return one of line, histogram, bands, markers, levels, table, panel |
| empty | The script ran without error and drew nothing | Legitimate for a marker script with nothing to mark; otherwise check warm-up and the reversed bar order |
Limits and pitfalls
- Scripts receive bars newest first: bars[0] is the most recent. Reverse before applying any formula.
- The language travels with the script (JavaScript by default, Python or C++ when chosen on the Scripting page). A Python script is run by the Python engine, not as JavaScript.
- Points whose time does not match a bar are dropped; non-finite values become gaps. A script cannot draw outside the chart.
- The editor has no syntax highlighting by design; the Run button and its exact error replace it.
Related pages
- Script outputs: overlay, pane, table and panel
- C++ scripts (WASM engine)
- Script assistant (AI)
- Cumulative delta explained
This page in other languages
Frequently asked questions
- I saved a script but nothing appears on the chart. Why?
- Saving and showing are two different actions. Turn on "Show on the chart" on the Scripting page or tick the script in the "My scripts" group of the Indicators panel.
- How many bars does the script receive?
- At most the 600 most recent bars of the chart, both in the editor's Run and on the live chart. Serialising a full day of bars with their levels would cost more than the calculation.
- Can my script access the network or my broker?
- No. The script runs in a worker where fetch, XMLHttpRequest, WebSocket, importScripts and global eval are overwritten before your code runs, the Tauri API is never imported, and the sandbox protocol adds a default-src 'none' policy. No file access, no broker API.