Messages and what fixes them

The builder shows one line and marks the row in the editor gutter. These are the messages you will meet, with the change that clears each one. The script is compiled and then run over one test bar as you type, so most mistakes are reported before the script ever reaches your chart. Where a message below starts with name, it names the call or the variable at fault.

Text and structure

MessageFix
Missing //@xfscript 1 headerMake //@xfscript 1 the first line of the script.
Empty scriptThe editor is empty. Paste the script.
Expected expression, foundA statement was split across lines, or an operand is missing. Put the whole call on one line.
Expected {Move the opening brace onto the same line as the if condition or the function signature.
Expected ) after argumentsA closing parenthesis is missing, or a call was split across lines.
Expected variable nameA let or var needs a name, and a reserved word such as for, while or if cannot be one.
Expected = after variable nameA let or var needs = and an initial value.
Unterminated blockA closing brace is missing.
Unterminated string literalA closing double quote is missing.
String literals cannot span linesUse \n inside one quoted string instead of a real line break.
Unsupported escapeOnly \n, \t, \" and \\ are supported.
Unexpected characterA character outside the language, such as a single quote, a backtick or a hash outside a string.
Unknown type nameTypes are float, int, bool, string, color, side and void.
Expected to in for loop (for i = start to end)Write for, the loop variable, =, the start, to, the end, and optionally by and a step.
break is only valid inside a loopbreak and continue must sit inside the loop itself, not in a function called from it.
Expected : in conditional expression (condition ? a : b)A ? needs its : and the second value.
Functions must be declared at top levelA fn cannot be declared inside another function. Move it to the top level.
Nested functions are not allowedA fn cannot be declared inside an if branch. Move it to the top level.
Persistent var declarations must be at top levelvar cannot be declared inside a function. Keep state in a top level var.
Series declarations must be top levelMove the let or var out of the if branch and assign inside it instead.
History access is only valid on a series identifierStore the expression in a let first, then index that name.
return is only valid inside a functionDelete the return, or move it into a function body.
Only a function call can be used as a statementA bare expression is not a statement. Assign it or call something.

Names

MessageFix
Unknown function nameThat name is not on this page. Check the spelling, or use a builtin that exists.
Unknown identifier nameThe name was never declared. Declare it with let or var before use.
Unknown series nameHistory was read from a name that is not a series.
Duplicate or reserved nameRename it. A global or builtin name cannot be reused.
Duplicate or reserved parameter nameA parameter repeats another, or reuses a series or global name.
Duplicate or reserved local nameA function local repeats a name already in use.
let series name is immutableDeclare it with var if you want to assign it with :=.
Assignment target name is not declaredDeclare the var above the assignment.
User functions are pure and cannot assign stateReturn a value from the function and assign it outside.
Recursive function cycle includes nameRemove the recursion. Recursion is rejected before the run.
Function locals are scalar and have no historyHistory indexing works on top level series only.
Loop locals are scalar and have no historyThe same for a let inside a loop body.
Loop variable name is read-onlyCopy it into a local, let j: float = i, and change the copy.
name cannot be a loop variable nameA loop variable cannot take a global, builtin or series name. Rename it.
Unknown identifier name; XF Script has ...A Pine name. The message names the XFlow Script equivalent, such as time.day for dayofmonth.
Effort Zones output can only be used on the bar it describesUse the Effort Zones value on the bar where you read it.
A script may declare indicator() at most onceKeep one indicator() call.

Arguments and types

MessageFix
name expects N arguments, received MCheck the signature on this page. Optional arguments are shown in brackets. Argument counts of the builtins are checked before the script runs, including inside a branch that never executes.
name requires int, received nanAnnotate as float, or wrap with nz and math.round.
name requires type, receivedThe value does not match the annotation. Change the annotation or the value.
name expects a number, receivedAn argument is of the wrong type. Strings and numbers are never coerced.
name expects bool, receivedA condition, an && or || operand, or a when argument is not a boolean.
name expects string, receivedText arguments must be strings. Format numbers with format.compact or format.fixed.
Expected #RRGGBB or #RRGGBBAA color, receivedColours are six or eight hex digits with a leading hash, and nothing else.
name style must be one of solid, dashed, dottedOne sentence covers every choice argument, and it lists what is accepted.
name shape must be one of x, circle, triangle, square, diamondThe same sentence for a marker shape.
name anchor must be one of above, belowThe same for an anchor.
name fill mode must be one of none, bullish, bearish, bullish_close, bearish_closeThe same for a zone fill mode.
plot.zone expects 3, 4, 7, or 8 argumentsUse the short form or the full event form, nothing between.
plot.zone start_offset must be an integer from -200000 through 0Move the left edge back by a whole number of bars.
plot.zone bars_right must be an integer from 0 through 200000Project right by a whole number of bars.
plot.box start_offset must be an integer from -200000 through 0The same rule for a box.
plot.box bars_right must be an integer from 0 through 200000The same rule for a box.
plot.segment bar_a and bar_b must be integer bar_index valuesPass bar_index values you stored, as whole numbers, never an offset or a time.
plot.text expects string textBuild the text with str.concat and the format builtins.
plot.label expects string textThe same for a readout line.
profile.fold bars_back must be an integer from 1 through 200000Fold a whole number of bars.
profile.fold value_area_percent must be finitePass a number such as 70.
profile.fold opacity must be between 0 and 1Opacity is a fraction, not a percent.
name index must be a non-negative integer or -1A row index is a whole number from 0 up, or -1 for none. A literal index below -1 is refused as you type.
tape.nth_largest_index rank must be a non-negative integerRank 0 is the largest print.
name depth must be a non-negative integerA depth argument is a whole number. Omit it or pass 0 for every level.
format.fixed decimals must be an integer from 0 through 6Pass a whole number of decimals.
name keeps one value per bar and cannot be called inside a loopCall it once per bar outside the loop and use its result inside.
name draws one value per bar and cannot be called inside a loopDraw objects inside a loop, such as plot.marker, plot.box or plot.hbar, or move the call out.
name declares a setting and cannot be called inside a loopDeclare inputs at the top level.
for step must not be 0Use a positive or negative step.
plot.polygon edges must not cross; list the points in order around the shapeOrder the points around the outline.
name bar offsets must be from -200000 through 500Keep plot.rect and plot.polygon positions inside the range.
plot.table row must be an integer from 0 through 19Rows are 0 to 19, columns 0 to 7.
profile.fold width_percent must be greater than 0 and at most 100Pass a percent, or nan for the chart look.
name timezone must be UTC, America/New_York, America/Chicago, Europe/Prague, Europe/London, Asia/Tokyo, Asia/Hong_Kong, Australia/Sydney, or a fixed offset in minutesName one of those zones, or pass whole minutes.
fn expects N argumentsA user function was called with the wrong number of arguments.
fn must return typeEvery path through a non void function needs a return of that type.

Inputs, sessions and bases

MessageFix
Inputs must be direct top-level variable initializersWrite let name = input.something(...) at the top level, on its own.
Input declarations require literal argumentsEvery input argument must be a literal, not an expression.
Duplicate input keyGive every input its own key.
input.int key must match [A-Za-z][A-Za-z0-9_]{0,63}Start the key with a letter and use letters, digits and underscore only.
input.int title must contain 1-80 charactersShorten or fill in the title.
input.int min must not exceed maxSwap the bounds.
input.int step must be positiveUse a step above zero.
input.int values must be integersWhole numbers only for input.int, including the step.
input.color default must be #RRGGBB or #RRGGBBAAWrite the default colour as a hex literal.
Session window must use HHMM-HHMMWrite the window as four digits, a hyphen and four digits, for example "0930-1600".
Unsupported session timezoneUse "UTC", "America/New_York", "Europe/Prague" or a whole number of minutes.
Session fixed offset must be an integer number of minutesPass whole minutes, such as -300.
Completed-session ranges require a daytime session windowsession.open and session.adr need a window that starts before it ends.
indicator(name, base): the base must be a string literalWrite the base as a literal such as "cvd".
Unknown base studyUse one of the open bases listed on this page.
That study is protected and cannot be a baseProtected indicators cannot be extended. The message lists the open bases.
base.* reads the declared base studyAdd the base to indicator("name", "base") before calling base.*.
base.series needs a literal series nameWrite the series name as a literal.
base has no seriesUse a series name the base publishes; the message lists them.

Limits

MessageFix
Source exceeds 65536 bytesShorten the script.
Token count exceeds 20000Shorten the script.
AST node count exceeds 10000Shorten the script, or move repeated logic into a function.
Calls accept at most 24 argumentsSplit a long str.concat into two.
Functions accept at most 16 parametersPass fewer values.
History offset must be an integer from 0 to 200000Use a whole number offset inside the range.
Plot count exceeds 64Reduce the number of distinct plot call sites.
Profile count exceeds 512Fold on a condition rather than on every bar.
Profile rows exceed 200000Fold fewer or shorter ranges.
plot.text accepts at most 8 linesReduce the number of \n breaks.
String exceeds 1024 charactersShorten the text.
Statement count exceeds 10000 on one barThe script does too much per bar. Simplify it.
Loop exceeded 100000 iterations on bar NA loop runs too often on one bar, or a while condition never turns false.
Loops exceeded 25000000 steps in one run (stopped on bar N)The loops do too much work over the whole window. Loop over fewer rows or fewer bars, for example only near last_bar.
Drawn objects exceed 250000 in one runA loop draws too many objects. Filter inside the loop, or draw only on recent bars.
Strings built on one bar exceed 200000Build text once per bar, not once per pass of a loop.
mtf.* reads at most 8 different timeframes in one scriptUse fewer different minutes values.
Call depth exceeds 32User functions call each other too deeply.
Series storage exceeds 8000000 cellsDeclare fewer top level series.
Input data exceeds 1000000 market itemsThe chart holds more data than one run may read. Load a shorter range.
Aggregate work exceeds 1000000 items on one barOne bar asked for too much whole bar work. Ask fewer distinct thresholds.
Script stopped after running longer than 8 secondsOne run took too long. The script does not run again until you edit it or change one of its settings. Do less work per bar.

Protected indicators from other users

MessageFix
This indicator stopped on bar N (limit or runtime error)The author's script stopped on the data of your chart. A protected script shows no more detail; try a shorter range, or ask the author.
Reload the page to run this indicatorA newer version is available. Reload the page.
This indicator is no longer availableThe author deleted it, or it was removed from the gallery.

Every layer of the market, Orderflow to optionflow, on one chart.

Institutional grade Orderflow data with backtesting and journaling built in. Join the waitlist for early access.

Get Access