FlowscopeDocs

Diagnostics

Stable compiler diagnostic codes of Flowscope Script, each with a failing and a corrected example.

Every message the compiler reports carries a stable code. The letter names the stage that found the problem; the number never changes meaning, so you can search for it, link to it and silence nothing by accident. Errors stop the script from running; warnings point at code that runs but probably does not do what you meant.

Parse (P…)

Problems found while reading the source text: characters, literals, line structure and syntax forms that Flowscope Script does not have.

CodeSeveritySummary
P001errorunrecognized token
P002errorunterminated string literal
P003errorsemicolon is not supported
P004errorword spelling of a logical operator
P005error?? mixed with && or || needs parentheses
P006errorwhile is not supported
P007errortemplate strings are not supported
P008error?. is not supported
P009errorpostfix ! is not supported
P011errortop-level statement is not a declaration
P014errorbreak and continue are not statements
P016errorexpected token
P021errorinvalid color literal
P022errorunknown string escape
P023errormatch arm in statement form needs a block
P024errormatch expression arm takes an expression, not a block
P025errorkeyword used as a name
P026errorternary broken before ? or :
P027errorsecond statement on the same line

Setup and declarations (S…)

Declarations that cannot be evaluated before the first bar, misuse of setup-only constructors, subscription arguments and alert declarations.

CodeSeveritySummary
S001errorlive value used in setup
S002errorbuilt-in cannot run in setup
S005errorcollection capacity must be known before the script runs
S006errorduplicate panel name
S007errorconstructor does not fit the declaration keyword
S008erroruser function called in setup
S011errorsetup value reads a later declaration
S012errorempty exchange list in subscription
S013errorcolor scale needs matching lists with at least two entries
S015errorminimum trade size must be positive and finite
S018errorlambda or collection transform in setup
S019erroralert constructor outside an alert declaration
S020errorinvalid alert payload type
S022errortrigger argument does not match the alert payload
S026errorsubscription history cannot be negative
S027errorthe chart subscription cannot be live only

Types and names (T…)

Name resolution and type checking. T0xx names and declarations, T1xx types and literals, T2xx calls, arguments and returns, T3xx user types and match, T4xx handlers, series, plots and lambdas.

CodeSeveritySummary
T001errorunknown identifier
T002errorduplicate top-level name
T005errorunknown type name
T006errorlocal hides a built-in namespace
T007errorname is already bound in this scope
T010errorscript header missing or misplaced
T011warningduplicate display title
T013warningunused binding
T014warningunused subscription
T016errorduplicate input key
T101errortype mismatch
T102erroroperator not defined for these operand types
T103errorfloat needs an explicit conversion to int
T106errorinvalid map key type
T109errortype is not indexable
T111errorinvalid timeframe literal
T112errorzero-length timeframe
T113errorinteger literal out of range
T114errorinvalid session literal
T201errorunknown named argument
T202errorpositional argument after a named one
T203errorargument supplied more than once
T204errormissing argument
T205errortoo many positional values
T206errorparameter default is not a literal
T207errorrequired parameter after an optional one
T208errornull default for a non-nullable parameter
T211errorwrong number of return values
T212errornot every path returns a value
T214errordestructuring does not match the returned values
T215errorno overload matches these arguments
T216errorvalue cannot be reassigned
T217errorinvalid assignment target
T301errortype field has no type annotation
T302errortype contains itself
T303errortype name is not UpperCamelCase
T304errormatch does not cover every case
T305warningnull arm on a value that cannot be null
T306errorrecord literal has wrong fields
T307errorduplicate field in a type
T401errorfunction calls itself
T402errorstateful calculation inside a loop
T403errorindicator inputs come from different timeframes
T405errorevent not available for this subscription
T406errorduplicate handler
T407errorhandler on a snapshot source
T408errorindicator on a calendar timeframe
T413errorindicator length must be known before the script runs
T414errorindicator length out of range
T415errorplot method does not match the panel
T416errorinvalid str.format template
T420errortrade fields are read-only
T422errorbook or profile view kept beyond the current call
T425errorfill has both a solid color and a gradient
T426errorlambda in an invalid position or with a block body
T427errorinvalid lambda parameter list
T428errorstateful call, randomness or drawing inside a lambda
T430errorcollection transform must be its own statement
T442errorrecord literal without a type name
T449warningisLast read in a close handler

Null safety (N…)

Places where a value that may be missing is used as if it were always present.

CodeSeveritySummary
N001errorvalue may be null here
N002errornull check on a field does not narrow it
N003errornull needs an explicit type

Collections (C…)

Arrays, rolling buffers and maps: read-only setup data, element types, capacities and subscription series.

CodeSeveritySummary
C001errorsetup collection is read-only
C003errorcollection cannot contain another collection
C004errorkey is missing from a setup map
C005errorempty array needs a capacity
C006errorsubscription series is read-only

Limits (L…)

Fixed resource limits per script: stateful calls, subscriptions, capacities, inputs, plots and alerts.

CodeSeveritySummary
L001errortoo many stateful call sites
L006errortoo many subscriptions
L007errorcapacity exceeds the supported limit
L008errornegative capacity
L010errortoo many inputs
L011errortoo many plots
L013errortoo many alerts
L015errorexpressions or blocks nest too deeply

Backtesting and strategies (B…)

The strategy declaration, order functions and broker emulator settings used by the Strategy Tester.

CodeSeveritySummary
B001errorstrategy order outside a handler
B002errorstrategy function without a strategy declaration
B003errormore than one strategy declaration
B004errorstrategy property set twice
B005warningexit refers to an unknown entry id
B006errorpyramiding is negative
B007errorquantity is not positive
B008errorcommission or slippage is negative
B009errorexit target given in ticks and as a price
B010errortrailOffset without trailPoints
B011errorleverage out of range
B012warningprocessOrdersOnClose combined with the bar magnifier
B013errorstrategy position read in setup
B014errorinitial capital is not positive

Internal (I…)

Failures of the compiler itself rather than of the script.

CodeSeveritySummary
I000errorinternal compiler error