Any Assay script as wired blocks — the seven colours of the blocks, a block's parts, the ladder, the building blocks, the Inspector, and the board as a node canvas with curved wires.
Every script in the IDE has a second face: the graph. It is the same script — not a copy, not a translation — drawn as blocks wired together, and anything you do on it is written into the text the moment you do it. Switch with the three icons in the IDE's header: Code, Graph, or Both side by side.
The text stays the script. The graph is drawn from it every time it changes, so a script you paste, open or type draws at once, comments and layout included, and a script you build on the graph is ordinary Assay text you can read, copy and run anywhere a version 5 or 6 script runs. Nothing about the graph is ever written into the script.
01The seven kinds of block
Every block belongs to one of seven categories, and the category is its colour and its icon. You can read a script's shape at a glance — where the data comes in, what is worked out, what is decided, what is drawn.
| Category | What it holds | Families |
|---|---|---|
| Data — lavender | the market's prices and the script's settings | Price, Ago, Input |
| Indicators — teal | averages and oscillators worked out over the bars | Average, Oscillator, Range, Highest / Lowest |
| Logic — magenta | questions that answer true or false | Crossing, Compare, Combine, Choose |
| Math — lime | arithmetic | Arithmetic |
| Output — rose | what the script draws or says | Plot, Colour, Alert |
| Flow — violet | when a line runs: a choice, a loop, a value kept across bars | Frame, Signal, Keep |
| Trade — the ink | a strategy's orders | Order |
Trade wears no colour, on purpose. An order is the one block that moves money, so it is drawn in plain ink among the coloured blocks — the strongest mark the sheet has, and never confused with the colours that mean buy, sell or a price.
The colours are the same ones the code editor uses where the two meet — a built-in call is teal in the text and an Indicators block is teal; a number is lime and Math is lime; if, for and var are violet and Flow is violet — so Both never shows one thing in two colours. Every icon stands on its colour, never beside it, so a block reads by its picture as well as its hue. Values, names and the functions and types the script writes itself are neutral: they are yours, not a category's.
02A block
A block reads like a short sentence:
- The tab at its left, filled with the category's colour and carrying the block's own icon — a candle for Close, a wave for an oscillator, a bell for an alert.
- The title — the name a trader uses: Simple average, Crosses above, Level line. Hover it for the code name (
ta.sma) and its signature. A function outside the building blocks shows its code name. If you would rather read code names on the blocks, set Block names to Code in Settings › Assay — the trader's name then moves to the hover. - Named slots — each input with its name, then what stands on it:
source ⟨close⟩ length ⟨14⟩. A call written with named inputs shows the names the script wrote. - A value — a number, a text, a switch, a colour — stands in a sunken pill. One press edits it in place: type, then Enter (Escape leaves it as it was). A true/false is a switch you press; a colour is a disc that opens the swatches.
- A name the script gives is a capsule with a small dot in the colour of the block that gives it. Hover it to light the row it comes from.
- A market value —
close,volume,bar_index— is a capsule tinted like Data, with its own icon. - A calculation inside a calculation is drawn as a smaller block inside the slot; past two levels deep it folds to a
…chip that opens on a press. - An operator (
close > open,a + b) stands between its two sides, its icon on the tab, as you would read it. - The result — the name the row gives its value, at the right end. A row that gives no name (a plot, an order) ends at the block.
At rest a block is just its tab, its title and its values. The controls appear under the pointer and on the picked block only: the ⌄ chip beside the title offers the block's own kind — ta.sma beside ta.ema, ta.wma and the other averages, > beside <, >= and the rest — keeping its inputs, and only the swaps that leave the script whole; a small × on a slot takes the value off, leaving na in its place for you to fill.
03The ladder
The graph opens as a ladder: one row per statement, top to bottom in the order the text runs them. Each row carries the script's own line number at its left — the number the Code face shows, so you can read across the two. The value flows left to right: what feeds a calculation, the calculation, then the name it gives.
- Under the pointerThe row lights across its whole width and shows its ⋯: Move up, Move down, wrapping and Delete the row.
- RenameDouble-press a row's name, type the new one, Enter — every place the script reads it is renamed with it.
- How a name keeps its valueThe mark before a kept name —
varorvarip— opens a menu: worked out each bar, kept across bars, or kept within the bar. - A line that does not readHalf typed, or not yet valid — stays on the ladder as a text row: a dashed outline with the line's own text, and one line under the graph's bar says how many such lines there are. Press it to edit the line in place.
- Moving rowsDrag a row's line number onto another row to put it below it. A row moves among the rows of its own frame.
- Picking rowsPress a line number to pick a row; Shift-press another to pick the rows between. Delete deletes every row picked, as one step.
Every change is one step Ctrl+Z takes back, on the graph or in the text.
04Building without typing
Building blocks, on the IDE's left rail, opens the palette beside the sheet:
- Seven category tabs run down its left edge, each the category's icon on its colour; press one to see its families.
- Families are headers, members are tiles. A tile is the block exactly as the sheet will draw it — its tab, icon and trader's name, with the code name beside it while the panel is wide enough. Press a tile to add it below the row you picked, or drag it onto a row — what you carry is the block itself.
- Hover a tile for a card: its icon large, its name, and the line it will write.
- Search blocks reads a trader's words as well as code names — moving average finds the averages, stop finds Cancel order. The building blocks come first, then All functions: every function and value Assay runs, each with its category's icon and colour, in the same list.
Each block writes one ordinary line — Simple average writes sma = ta.sma(close, 14) — with a name the script does not use yet and a sensible starting value for every required input.
A script that holds only its declaration shows a quiet picture in place of an empty sheet: three ghost blocks — a price, an average, a line on the chart — wired together, and a dashed fourth inviting the first block in. Drag a block here, or press one. The picture is only a picture; it takes no press.
05The Inspector
On the Graph face the right side of the window is the Inspector: the block you picked, as a form, so you can change a length without knowing it is the second input.
- At the top: the block's icon on its colour, its trader's name and its code name.
- One row per input, the required ones first, each with the control its value takes: a number field with − and +, a switch for true/false, a text field, the swatches for a colour, and for a series a menu of every name given above this row whose type fits — a name that needs a conversion is listed with it — then the market's own prices.
- More lists the optional inputs the script has not written, each with a + that writes it.
- At the foot: Change to… (the same swaps as the
⌄chip), Show in code, and Delete the row.
With nothing picked it says Pick a block to see its inputs here. Every change in the Inspector is the same change a press on the sheet makes — one step Ctrl+Z takes back.
06Frames and functions
An if is drawn as a bracket in the Flow colour, the shape block editors taught everyone: a header with its condition, a rail down the left of its body, and every arm — if, else if, else — as a band with its label and its rows inside. A switch draws its cases the same way; a loop draws its header and its body. Any frame folds and unfolds at its header, and folded it says how many rows it holds.
Pick rows and the row's ⋯ offers:
- Wrap in if, Wrap in a loop, Wrap in while — the rows moved one level in under a new header that changes nothing until you change it (
if true, a loop that runs once). A wrap that would hide a name a later row reads is refused, with the line that reads it. - Make a function of itThe rows become a function of their own, the names they read from earlier rows its inputs and the last row's name its value, called where the rows stood. The plotted values are the same before and after.
- UnwrapA frame of one arm, its rows one level out.
A function you write is a neutral container folded to its name and its inputs; unfold it to see its body. A type and an enum are cards of their fields and members.
A name kept with var and given a new value later is drawn with the only wire that runs upward: a dashed curve in the Flow colour from the row that sets it back to the row that keeps it — the value carried into the next bar.
07The board — a node canvas
The graph's own bar switches between Ladder and Board. The board is the same script laid out by hand, on a dotted surface:
- Each statement is a node: a header in its category's tint with the block's tab, icon and title, and a grip at its right end; then one line per input, its socket on the left edge, the input's name and what stands on it; and on the right edge the name it gives, its socket just outside.
- A socket's shape says its type: a disc for a number, a diamond for true/false, a square for a text, a ring with a filled centre for a colour, a plain ring for anything else. A socket is hollow while a value stands on it and filled when a wire arrives.
- Wires are curves, leaving and arriving level. They are neutral in colour; their pattern repeats the socket's type — solid for a number, dashed for true/false, dotted for a text, beaded for a colour, doubled for anything else. A wire whose source stands to the right of its reader loops around the two nodes and carries an arrowhead where it arrives, so the direction is never read from position.
- A calculation inside a calculation stands as smaller nodes to the left of the input it feeds, one column per level, held together in the statement's frame — a formula becomes a small circuit.
- A frame — an
if, a loop — is a container node with its rows inside. A name read inside it from outside enters through a tunnel: a small square on the container's left edge where the wire ends, labelled with the name.
Wiring, socket to socket
Press a statement's output socket — or the name it gives — and drag. A curve follows the pointer, and while you hold it every input socket says whether it can take it: ringed and grown when it fits, with the conversion's name beside it when it fits through one (int, str.tostring), faded when it cannot. Sockets the text forbids — the statement's own, any above the one that gives the name, another scope — fade too, and say why on hover (written on line 7, after this one).
Release on a socket and the name is written there — one change, one Ctrl+Z step. Release on a socket that refuses, and nothing is written: one line under the bar says why, led by the two socket shapes that did not meet. Release on the empty board, and nothing happens.
From the other end: drag a wired input's wire off. Dropped on another output it reads that name instead; dropped on the empty board it takes the value off. Hover a wire to bring it forward with its name and type (sma · float) while the others quiet; press it to pick it, and Delete takes the value off its input.
Order, and moving things
Because position on the board is your choice, the order the script runs in is drawn on its own: every node carries a numbered badge on its top-left corner — its line number — and a dotted order thread runs from badge to badge in the text's order, always, beneath the wires. Show order on the board's bar holds the thread at full strength. To change the order, drag a badge onto another badge — that moves the statement in the text, exactly as moving a row does.
Dragging a node — by its grip or its empty room — never changes the text. A node dropped lands on the board's grid; the script stays byte for byte the same. Drag the empty board to pan, and Fit brings every statement into view. The first time you open the board, a small picture says it once: Blocks run in the order of their numbers.
The board reads left to right: a node's inputs are on its left, its result on its right. When the text changes — typed, pasted, written by a block — every statement keeps its place, and a new one lands in the column after the statements it reads (one that reads nothing lands in the first column), outlined for a few seconds so you see where it fell — so a wire runs from a result on the right of one node to an input on the left of the next. Tidy lays the whole board again the same way; Forget the arrangement deletes it and returns to the ladder. A node you carry to the left of its source still works: its wire loops back and carries an arrow where it arrives.
An arrangement is kept beside the script, in the indicators folder's .boards folder, never inside it: a script you copy elsewhere opens there as the ladder.
08What a run shows on the sheet
After a run (F5), the graph reads the bar the Inspector view is on:
- The arm that did not run on that bar is dimmed, so you see at a glance which
iffired. - The probe (the pointer icon on the graph's bar) shows each name's value at that bar beside it; walk the bars and the values follow.
- Heat: a strip under each line number, as long as that statement's share of the run's time.
- Stepping to another bar lights the rows that ran on it for a moment.
09For agents
An agent reads the graph with ide_graph — every row, its kind and line, every block with its kind, its label and the lines its text stands on — makes any gesture of the sheet with ide_graph_edit, exactly as a person's press or drag (one Ctrl+Z step for the person), and reads or arranges the board with ide_board, which changes no byte of the script. See indicators and scripts.
10A picture of the graph
bentrix --graph-svg <file.assay> --out <file.svg> writes a script's graph as an SVG picture, with no window — the ladder, or the board with --board. It is drawn by the same code as the sheet, letters included, so it looks exactly as Bentrix draws it, and it carries the light and the dark theme in one file. See the command line.