Script Editor
The Script Editor is where you write, save and manage your own indicators and
strategies. A saved script appears in every chart's indicator list under My
scripts; a script declared with strategy() also reports its backtest in the
Strategy Tester.
The toolbar
| Control | What it does |
|---|---|
| New | Start a new, untitled script. |
| Refresh | Reload your saved scripts from your account. |
| Examples | Load one of the built-in example scripts as a starting point. |
| Open | Open a script from a file on your computer. |
| Compose with AI | Show or hide the AI composer beside the editor. |
Compose with AI
Compose with AI opens a conversation beside the editor. Describe the indicator or strategy you want in plain words, or ask for a change to the open script, and the script is typed into the editor as it is generated. Each reply is compiled on the spot: if the compiler objects, the composer asks the AI for a fix once by itself, and after that Ask AI to fix sends the problems back whenever you choose.
- Try one starters cover price studies, order flow, open interest and strategies; More ideas rotates them.
- Skip shows the whole script at once while it is still being typed; Stop (Esc) ends a reply and keeps what has arrived.
- Revert on a reply puts the previous version of the script back.
- An untitled script takes the title the AI gave it in
study()orstrategy(). - Every reply carries the whole script, so what you save is never a fragment. Nothing reaches your account until you press Save.
The composer answers only what concerns scripts: writing one, changing the open one, and questions about the language, the data or the library. Anything else gets a one-line refusal, which still counts toward the day's allowance.
The composer is included in the Pro and Max plans (trials too) with a daily allowance per account, shown under the prompt box; it resets at midnight IST. Conversations are kept per script for the session. Each request sends the script in the editor and the earlier turns of that conversation, so the AI revises what you see; your charts, account and saved scripts are not sent.
My scripts
The list on the left holds your saved scripts, each with its saved status and version. Click one to open it.
Editing
| Control | What it does |
|---|---|
| Script name | The name shown in the chart's indicator list. |
| Format source | Tidy the indentation and spacing of the code. |
| Download source | Save the script as a file. |
| Save | Save the script to your account (Ctrl/⌘ S). |
| Save copy | Save under a new name, leaving the original unchanged. |
| Delete | Remove the script. |
Below the editor:
- Inputs lists the inputs the script declares, with their defaults.
- Problems shows what the compiler reports, or that the script compiles.
- Data reference lists the order-flow, open-interest and footprint series a script can read (the data contract below).
- Import Pine draft converts a Pine Script draft into the editor as a starting point; review the result before saving.
- Open saved version returns to the last saved copy.
Data contract (v2)
Besides open, high, low, close, volume, oi and time, a script reads
three FutPrint namespaces on the chart interval. Every value is a plain number
per bar; a missing value is none. The Data Inspector shows the same rows
and Capture ▸ CSV exports the same columns (flow.delta, oi.change,
fp.poc, …), so the numbers agree everywhere. flow.version, oi.version and
fp.version report the contract version, 2.
The feed is one Level-1 row per symbol per second with a side inferred by the backend from the price move, not an exchange aggressor flag; open interest is a level re-sent on traded rows. Everything below is built from that.
flow.* — order flow
| Series | Meaning |
|---|---|
flow.available | 1 when the bar has a buy/sell split, else 0. |
flow.buyVolume, flow.sellVolume, flow.delta, flow.deltaPercent | Buy-side and sell-side volume from the inferred side of each one-second row, their difference, and delta as a % of classified volume. |
flow.deltaHigh, flow.deltaLow | Highest and lowest running delta inside the bar, for verified chronological data only. |
flow.trades, flow.buyTrades, flow.sellTrades | Feed-reported trade counts. |
flow.cvd | Cumulative delta over the contiguous run of loaded bars; restarts after gaps. |
flow.sessionCvd | Cumulative delta since the first bar of the calendar day in the chart's time zone, the CVD indicator's Session reset. |
oi.* — open interest
| Series | Meaning |
|---|---|
oi.available | 1 when the bar carries an OI level. None for an untraded contract, and never on an index or an equity. |
oi.value | OI at the end of the bar, in contracts (the same level as the bare oi series). |
oi.prev | OI at the end of the previous chart bar, not the previous day. |
oi.change, oi.changePct | Bar-over-bar change of the level and that change as a % of oi.prev, as Bar Statistics shows them. |
oi.buildup | Price × OI quadrant against the previous bar: 2 long build-up, -2 short build-up, 1 short covering, -1 long unwinding, 0 when either change is zero, none when this bar or the previous one has no OI level. The sign follows price; 2 in size means OI rose. |
fp.* — footprint structure
Built from the bar's traded price levels as the feed reports them (no display
binning). Footprints are not served for index symbols or on the Free plan, so
fp.* is none there; on a plain OHLCV chart only bars built from live rows
carry levels.
| Series | Meaning |
|---|---|
fp.available | 1 when the bar has a buy/sell split per price level. |
fp.levels | Number of traded price levels. |
fp.poc, fp.pocVolume | Price level with the most volume (lowest on a tie) and its volume. |
fp.vah, fp.val | Top and bottom of the 70% value area grown outward from the POC, higher-volume side first. |
fp.pocPosition | 100 × (poc − low) / (high − low): 0 at the low, 100 at the high. |
fp.buyImbalances, fp.sellImbalances, fp.imbalances | Diagonal imbalance counts at the chart's footprint ratio (buy at a level against sell one level below; sell against buy one level above) and their difference. Zero volume never counts. |
fp.imbalanceRatio | The ratio the counts were made with: the chart's Footprint ▸ Imbalance threshold at run time, pinned so the script can see it. |
fp.cotHigh, fp.cotLow | Net volume (buy − sell) traded after the bar's high and low were set. |
These namespaces read the chart interval only; inside req.timeframe or
req.symbol they are rejected. Scripts that read them run on the chart;
server-side script alerts still evaluate price and volume series only.
The OI build-up and Footprint structure examples show each namespace
in use.
Using a script on a chart
- 1Save the script
Scripts must be saved to your account before a chart can use them.
- 2Add it from the chart
On a chart, open Indicators and choose it under My scripts.
- 3Set its inputs
Each chart keeps its own input values, independent of the defaults in the editor.