Errors and warnings¶
Find the code shown in your strategy diagnostic, then apply the suggested correction. Errors block validation; advisories need review. Begin with fix a strategy error for common mistakes.
Fix the earliest relevant syntax error, then check again: one missing delimiter can cause later diagnostics. Find an exact code with page search or site search. An advisory about an unknown input or execution capability still needs resolution before relying on the rule.
Strategy structure and syntax¶
| rule | when it fires | how to fix |
|---|---|---|
TS-VERSION |
The //@version=N pragma names a grammar version this build doesn't support. |
Use //@version=1 as the first non-comment line, or omit the pragma to use version 1. |
TS-PARSE |
The strategy text couldn't be parsed and the failure didn't map to a more specific TS-PARSE-* code. The message names the offending line and token. |
Fix the reported syntax at the given line. |
TS-PARSE-UNKNOWN-SECTION |
A top-level line isn't a known section header — a typo, or a body row that landed outside its section. Indentation is optional, so a body row is placed by the section header above it; a stray row with no section above it lands here. The error carries a did-you-mean when a close match exists. | Use a supported section (symbol/universe, run, size, risk, entry, exit, stop/target/trail, stop_at/target_at, hold, define), and make sure entry/exit rows follow their entry: / exit: header. |
TS-PARSE-CLAUSE-KEYWORD |
An entry/exit clause contains a likely misspelling of when: such as wen: or whn:. |
Use when: after long or short. |
TS-PARSE-EMPTY-VALUE |
An instrument scope (symbol: / universe: / pairs: / options:) was declared with no value — nothing after the colon and no following value line. |
Give it a value: symbol: RELIANCE, or a block/inline list for universe:. |
TS-PARSE-VERSION |
An explicit version pragma is malformed, repeated or placed after declarations. | Use //@version=1 once as the first non-comment line, or omit it to use version 1. |
TS-PARSE-EMPTY |
The strategy has no parseable (non-blank, non-comment) lines. | Provide an instrument scope, explicit sizing and an entry: or hold: body. The version pragma is optional. |
TS-PARSE-UNTERMINATED-COMMENT |
A /* block comment reaches the end of the file without a closing */. |
Close the block with */; the diagnostic points to the opening delimiter. |
TS-PARSE-UNEXPECTED-COMMENT-CLOSE |
A */ appears outside an open block comment. |
Remove the stray closer or add the intended /* opening delimiter. |
TS-PARSE-NESTED-COMMENT |
A second /* appears before the current block comment closes. |
Close the current block with */ before opening another block comment. |
TS-PARSE-MULTILINE-STRING |
A quoted string value is assembled across physical lines. | Keep the complete string on one physical line; use \n for a newline in its value. |
TS-PARSE-NO-SCOPE |
No instrument scope was declared. | Add symbol: or a fixed explicit universe: list. |
TS-DUPLICATE-SECTION |
A unique top-level section repeats, including risk, stop_at, target_at and all scalar declarations. The message locates both headers. |
Keep one header and combine its rows. Instrument scopes are mutually exclusive. Only define, entry and exit remain repeatable; existing rule lists accumulate. |
Sizing, allocation and limits¶
| rule | when it fires | how to fix |
|---|---|---|
TS-SIZE-MAP-SYNTAX |
A quantity map has an invalid value or missing delimiter. | Use size: {NAME: N units, ...} or {PAIR: N lots, ...}; percentage allocation belongs in allocate:. |
TS-SIZE-MAP-NAMES |
Quantity map names do not match the complete explicit instrument scope, or a key is invalid. | Match every authored symbol exactly, including case and exchange qualifiers; use names of at most 128 characters. |
TS-SIZE-MAP-DUPLICATE |
An instrument occurs more than once in a quantity map. | Declare exactly one target per eligible instrument. |
TS-SIZE-MAP-MIXED |
One map mixes quantity kinds or also declares a scalar sizing objective. | Use only units or only lots in one map, with no scalar value or local quantity override. |
TS-SIZE-MAP-RANGE |
A quantity map exceeds the instrument limit. | Use at most 500 explicit eligible instruments. |
TS-SIZE-SYNTAX |
A size: value is incomplete, out of order, or has trailing text. |
Use one complete form from the sizing guide, such as size: 10% of portfolio per instrument. |
TS-SIZE-RANGE |
A percentage is not greater than 0% and at most 100%, or a unit quantity is not positive. | Use a percentage in (0%, 100%] or a positive whole-unit quantity. |
TS-RESIZE-SYNTAX |
A resize cadence is unsupported. | Use resize: daily or resize: weekly with vol target sizing. |
TS-RESIZE-SIZE |
Resize is used with another sizing objective. | Only vol target supports scheduled size-only resize. |
TS-SIZE-KIND |
The sizing objective is unsupported. | Use percentage exposure, units, Forex lots, stop risk, or vol target. |
TS-SIZE-BASIS |
The money basis is unsupported for this objective. | Use portfolio or starting capital with exposure/risk; units, lots and vol target have no authored money basis. |
TS-SIZE-STOP |
An inline stop is invalid or used with another objective. | Use a positive fixed-percent inline stop with risk sizing. |
TS-SIZE-VOL |
Vol target history or target period is invalid. | Use annualized (default), monthly or daily, and at least two daily returns (63 by default). |
TS-SIZE-ENTRY-SHAPE |
Explicit sizing is used with an unsupported execution shape. | Use independent instrument signals or a hold book; pairs and options sizing remain deferred. |
TS-SIZE-DUPLICATE-INSTRUMENT |
The eligible universe repeats an instrument. | List each eligible instrument once. |
TS-SIZE-MIXED-SHAPE |
Entry signals and a hold selector both control exposure. | Choose one execution shape. |
TS-SIZE-DYNAMIC-UNIVERSE |
Sizing requires an eligible list that cannot be enumerated. | Use a fixed explicit instrument list for this iteration. |
TS-SIZE-RISK-HOLD |
Stop-risk sizing is used with hold selection. | Use risk sizing with independent entry signals. |
TS-ALLOCATE-HOLD-DICTIONARY |
A fixed dictionary accompanies hold selection. | Use equal weight or inverse volatility; fixed hold dictionaries remain deferred. |
TS-ALLOCATE-NAMES |
Dictionary keys do not match the full eligible universe. | Include every eligible instrument exactly once, with no other keys. |
TS-ALLOCATE-WEIGHTS |
Dictionary weights are invalid or do not total 100%. | Use positive finite weights summing to 100%; no automatic normalization occurs. |
TS-ALLOCATE-NAME |
A dictionary key is not a canonical instrument name. | Use eligible instrument names as keys. |
TS-ALLOCATE-SUM |
Dictionary percentages do not sum to 100%. | Correct the authored weights; they are never silently normalized. |
TS-RESIZE-CONFLICT |
Resize declarations disagree. | Keep one daily or weekly resize declaration. |
TS-SIZE-DUPLICATE |
A volatility modifier is repeated. | Declare the target period, scope and lookback only once each. |
TS-SIZE-RISK-STOP-CONFLICT |
Inline and separate execution stops conflict. | Use one fixed percentage stop for sizing and execution; identical copies are accepted. |
TS-SIZE-VOL-LOOKBACK |
A volatility lookback has fewer than two daily returns. | Use at least two daily returns; the default is 63 returns from 64 completed daily closes. |
TS-ALLOCATE-SYNTAX |
An allocate: value is not one of the closed allocator forms. |
Use allocate: equal weight, allocate: inverse volatility over N bars, or an exact eligible-name percentage dictionary totaling 100%. |
TS-ALLOCATE-RANGE |
The inverse-volatility allocator lookback is not a positive integer. | Use a positive whole-bar lookback, for example inverse volatility over 63 bars. |
TS-ENTRY-SIZE-SYNTAX |
An entry includes an unsupported local quantity phrase. | Use long N units, short N units, or Forex long L lots / short L lots, or use top-level size:. |
TS-ENTRY-SIZE-RANGE |
A local entry quantity is not positive. | Use positive whole units or a positive plain-decimal Forex lot target. |
TS-RISK-SYNTAX |
A risk: clause is outside the closed cap grammar. |
Use max N% per instrument and/or gross <= N%; advanced constraints are parked until their capital semantics are specified. |
TS-PYRAMID-SIZING-UNSUPPORTED |
Pyramiding uses tranche quantities that are not yet tied to the explicit sizing basis and cap. | Remove add / partial-exit tranches until explicit tranche sizing is supported. |
TS-PYRAMID |
A pyramiding (add / partial exit) rule is unsafe or ill-formed — averaging down (every -X%) or a qty add without the required cap, an add with no opener, pyramiding on a hold: book, or a non-positive amount/move. |
Cap the dangerous branch (max adds/units/exposure/qty), declare an opener, keep it in the entry/exit archetype, and use positive amounts. |
TS-SIZING |
An exposure-producing strategy has no explicit sizing intent, or a declared v1 policy / allocator is unknown. TradeScript never supplies an implicit quantity. | Add a complete size such as size: 10% of portfolio per instrument, or put a whole-unit target on every entry. Every hold: book needs explicit size: intent. |
TS-SIZE-TYPED |
A size reached validation without a typed sizing specification. | Use a complete canonical size form; report this as a parser/validator drift bug if the source already uses one. |
TS-SIZE-SCOPE |
A size scope does not match its strategy shape, or the strategy shape does not support explicit sizing yet. | Use per instrument for independent entry signals or in total for one shared budget. Pairs/options are parked until their sizing contracts are explicit. |
TS-SIZE-RISK-STOP |
Risk-per-trade sizing has no fixed-percentage stop. | Add a fixed percentage stop:, or choose exposure/share sizing. ATR, level, and dynamic stops are not accepted for risk sizing. |
TS-SIZE-MIXED-TARGET |
A local whole-share entry target is mixed with a shared active or portfolio money budget. | Remove the local target, or switch to independent per instrument sizing. |
TS-ALLOCATE-NO-BUDGET |
allocate: is declared with independent per-instrument sizing. |
Remove allocate:, or choose in total when one shared budget is intended. |
TS-ALLOCATE-RISK |
allocate: is combined with independent risk-per-trade sizing. |
Remove allocate:; each trade has its own risk budget. |
TS-ALLOCATE-DUPLICATE |
Both allocate: and hold: declare relative allocation. |
Keep exactly one allocation source. |
TS-DUPLICATE-RISK |
The same risk-cap kind is declared more than once. | Keep one max ... per instrument and one gross <= ... declaration at most. |
TS-SIZE-CONTRADICTION |
A per-instrument size is statically larger than the declared per-instrument maximum. | Lower the size or raise the cap so the declarations can both be true. |
TS-SHARED-BUDGET-PYRAMID-UNSUPPORTED |
Pyramiding is used with in total. |
Remove pyramiding; tranche sizing is outside the current executable contract. |
TS-SIZE-BUDGET |
A literal multi-symbol universe using independent percentage sizing can request more than 100% gross exposure when enough names trigger together (advisory). | Reduce the per-instrument percentage, declare an appropriate gross cap, or use one shared in total budget. |
Conditions and definitions¶
| rule | when it fires | how to fix |
|---|---|---|
TS-RESERVED |
An expression calls an execution/reflection builtin or uses a reserved name. | Use strategy expressions and explicitly supplied indicator providers. Rename reserved definitions and bindings; bare open remains the opening-price field, but open(...) cannot access files. |
TS-MEMBER |
Member access (orb.high) is used on something that isn't a session_range(...) binding, or names a field the session range doesn't have. |
Access .high / .low / .range / .avg_volume (also .width / .mean_volume / .total_volume / .bars) on a define <name> = session_range(...) binding. |
TS-OPPOSITE-SYNTAX |
The English opposite phrase is incomplete or does not select long/short. | Use opposite of long, opposite of short, or the one-operand call spelling. |
TS-OPPOSITE-ARITY |
An opposite call has the wrong operand count or call shape. | Pass exactly one side selector, single-line boolean define, or directional condition. |
TS-OPPOSITE-LIMIT |
An opposite-bearing expression exceeds bounded parsing or expansion. | Simplify the condition; resolved depth is capped at 80 and output at 10,000 expression nodes. |
TS-OPPOSITE-DEFINE |
A referenced define is missing, duplicated or lacks a supported boolean result. | Use one unambiguous single-line boolean define, or write the counterpart explicitly. |
TS-OPPOSITE-CYCLE |
A referenced boolean or numeric definition contains a cycle. | Remove the cycle and keep definitions a finite composition. |
TS-OPPOSITE-PREDICATE |
A condition cannot be mechanically reversed, or hides a boolean/state predicate in a numeric operand. | Use ordered comparisons/crosses with AND/OR; keep shared eligibility outside opposite. |
TS-OPPOSITE-NESTED |
An opposite operand contains another opposite operation. | Select an explicit directional source instead of nesting derivations. |
TS-OPPOSITE-SOURCE |
A side selector has no unique explicit other-side source in its own section. | Declare exactly one explicit source and select it from the other side in the same entry/exit section. |
TS-OPPOSITE-CONFLICT |
A side-derived rule conflicts with another explicit destination row. | Keep one derived destination or author the destination conditions explicitly. |
TS-OPPOSITE-CONTEXT |
Opposite is used outside an admitted entry/exit boolean condition or strategy family. | Use an ordinary independently sized symbol/universe conditional strategy; write unsupported contexts explicitly. |
TS-LOOKAHEAD |
A bar offset looks ahead — a negative or computed-negative index like close[-1] or close[0-1], or a non-constant offset. |
Use a non-negative constant offset: [0] is the current bar, [1] the prior bar. |
TS-DEFINE |
A define is malformed — a block with no result =, a self-reference, a forward reference between bindings, or an invalid (non-identifier) name. |
Make it a top-down, loop-free composition with a valid name and a final result =. |
Schedules, exits and availability¶
| rule | when it fires | how to fix |
|---|---|---|
TS-ENTRY-BATCH-SCOPE |
even if holding accompanies an unsupported execution shape or sizing policy. |
Use one-direction symbol/universe entries with independent units, lots, percentage or stop-risk sizing. Remove shared budgets, hold, pairs/options, mixed directions, opposite, pyramiding and volatility resizing. |
TS-HOLD-EXIT-IGNORED |
An exit clause accompanies a hold selector (advisory). | Hold controls membership; the exit clause is ignored. Put the condition in the hold selection if needed. |
TS-SCOPE |
An action/section is used with the wrong scope — e.g. hold: without universe:, the spread without pairs:, an option structure or hedge: without options:. |
Use a supported symbol or fixed-universe strategy shape; hold requires a universe. Pair/options syntax remains unsupported. |
TS-SESSION-EXIT-SCOPE |
A session-relative timed exit is used for a composite pair position, whose entry timestamp is not yet represented by the single-position runtime contract. | Use a supported symbol or fixed-universe strategy for session-relative exits. |
TS-SESSION-EXIT-OVERNIGHT |
A session-relative timed exit is combined with a run window that crosses midnight; market-local dates cannot identify those venue sessions safely. | Use a same-date run window until venue-calendar session boundaries are supported. |
TS-SESSION-EXIT-CADENCE |
The declared timeframe has no evaluation at or after a session-relative exit clock before the run window closes (advisory, never an error). | Use a finer timeframe or an earlier exit clock when same-session execution is required. |
TS-PROVIDER |
A name isn't a known catalog provider. A close match is a likely typo (error + did-you-mean); a genuinely unknown name is an advisory (assumed injected — validate --strict promotes it to an error). |
Fix the typo, or confirm the provider is bound at deploy. See the provider reference. |
TS-DEPRECATED |
A construct still works but has a newer canonical form — e.g. exit <amount> for a partial scale-out (superseded by reduce <amount>; exit/close now flatten fully). |
Switch to the canonical form named in the advisory (e.g. reduce <amount>). |
TS-CADENCE |
The run: cadence position holds an unrecognized token. A close typo (monthy) is an ERROR with did-you-mean; a genuinely-unknown but plausible cadence (fortnightly) is an ADVISORY (surfaced, never silently accepted) since the orchestrator may honor custom cadences. |
Use a known cadence (daily/weekly/monthly), a timeframe (5min/1d), or confirm the orchestrator honors the custom cadence. |
TS-PROTECTION-VALUE |
A protection value is empty, malformed, nonpositive, nonfinite, has an unknown unit or contains trailing text. It cannot compile without protection. | For stop/target/trail use positive finite N%, N percent/pct/percentage, ATR or N ATR, or N point/points/pt/pts. For stop_at/target_at use a numeric absolute-price expression. Inline risk sizing accepts only a fixed N% stop with 0 < N <= 100. Time stops accept complete after N days/bars, at HH:MM or session-clock forms. The diagnostic includes the value, allowed forms and source location. |
TS-STOP-AMBIGUOUS |
A protective stop, target, or trail is a bare number whose unit could be percent, fraction, or price. | Add an explicit unit, such as stop: 3% or stop: 2 ATR. |
TS-SLICE |
A hold: slice word isn't recognized — neither a known fraction (half/third/quartile/quintile/decile) nor a positive integer count. |
Use a fraction word or an absolute count (top 3, bottom 10 by score). |
TS-APPROX |
at turn of month is valid but lowers locally as a monthly point rebalance rather than a true turn-of-month holding window (advisory, never an error). |
No syntax change is required; treat the local result as a clock-shape check until the exact calendar-window primitive ships. |