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 |
|---|---|
| Compose with AI (A) | Show or hide the AI composer beside the editor. |
| New (N) | Start a new, untitled script. |
| Examples | Load one of the built-in example scripts as a starting point. |
| Open (O) | Open a script from a file on your computer. |
| ⋯ | The file actions below, Reload saved scripts and the keys. |
On a narrow panel Code | AI switches between the editor and the composer.
Compose with AI
Compose with AI opens a conversation beside the editor. Describe the indicator or strategy you want, or a change to the open script, and the script is typed into the editor as it arrives. Each reply is compiled: if the compiler objects, the composer asks the AI for one fix by itself; after that Ask AI to fix sends the problems back.
- Try one starters cover price studies, order flow, open interest and strategies; More ideas rotates them.
- Skip shows the whole script at once; 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; nothing reaches your account until you press Save.
The composer answers only questions about scripts, the language, the data or the library; anything else gets a one-line refusal that still counts toward the day's allowance.
The composer is included in Pro and Max (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; your charts, account and saved scripts are not sent.
My scripts
The list on the left holds your saved scripts, each with its version, or Draft. Click one to open it. On a narrower panel the button with the script's name (L) shows it.
Editing
| Control | What it does |
|---|---|
| Script name | The name shown in the chart's indicator list. |
| Save | Save to your account (Ctrl/⌘ S); beside it, Unsaved or Saved · v3. |
| ⋯ ▸ Format source | Tidy indentation and spacing. |
| ⋯ ▸ Download source | Save the script as a file. |
| ⋯ ▸ Save a copy | Save under a new name, leaving the original unchanged. |
| ⋯ ▸ Import Pine draft | Convert a Pine Script draft; review it before saving. |
| ⋯ ▸ Open saved version | Return to the last saved copy. |
| ⋯ ▸ Delete script… | Remove the script after Confirm delete. |
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).
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, apart from the editor's defaults.