Skip to content

Script declaration ​

Every script starts with exactly one strategy() or indicator() call at the top level.

NameDescription
strategy()Declares the script a strategy: it can trade.
indicator()Declares the script an indicator: it only draws.

strategy() ​

ts
strategy(config: StrategyConfig): void

Declares the script a strategy: it can trade. Call it exactly once, at the top level.

Types: StrategyConfig

indicator() ​

ts
indicator(config: IndicatorConfig): void

Declares the script an indicator: it only draws. Call it exactly once, at the top level.

Types: IndicatorConfig

Types ​

StrategyConfig ​

Configuration of a strategy script (strategy()).

FieldTypeDescription
namestring
version?"0.1"
marketMarketthe subnet traded; on the AlphaForge chart the chart's subnet replaces it
resolutionResolutionbar size; on the AlphaForge chart the chart's interval replaces it
capital?{ tao: number }starting cash (default 100 TAO); the Strategy tester's capital setting overrides it when set
actOn?ActOnwhen event.onCandle fires (default "confirmed")
calcOnEveryBlock?booleanalso call event.onBarUpdate on every update of the open bar
fill?FillConfig
fees?FeeConfig
risk?RiskConfig
overlay?boolean

IndicatorConfig ​

Configuration of an indicator script (indicator()).

FieldTypeDescription
namestring
shortTitle?stringlegend title on the chart (e.g. "BB" for Bollinger Bands); defaults to name
version?"0.1"
overlay?booleantrue: drawn on the price pane; false: in its own pane below the chart
resolution?Resolution
precision?numberdecimals of the values in the legend and on the price scale; default: the symbol's
format?"price" | "percent" | "volume"how values are formatted: price (default), percent, volume (k/M suffixes)
titleInputs?string[]names of the inputs shown in the legend title, in order; default: every int/float/source/select input

FillConfig ​

How intents fill in a backtest. The fill mode itself (quick, precise or 1B) is chosen in the Strategy tester's settings.

FieldTypeDescription
mode?"quick" | "precise"not read by the runtime; the Strategy tester's fill setting decides
latencyBlocks?numberblocks between intent creation and earliest fill (default 2)
defaultToleranceBps?numberdefault max/min price tolerance when an intent gives none (default 100)
rateLimitBlocks?numberstake rate limit between ops on one market (default from chain params)

FeeConfig ​

Trading fees, in basis points of the TAO side.

FieldTypeDescription
protocolBps?numberthe chain's protocol fee (default: the chain parameter)
platformBps?numberan extra platform fee added to every fill (default 0)

RiskConfig ​

Risk limits. Order-level rules reject the intent with reason risk:<rule>; drawdown and daily loss stop the run.

FieldTypeDescription
maxPriceImpactPct?numberreject a fill whose price impact exceeds this percentage
maxOrderTao?numberreject a buy larger than this many TAO
maxPositionTao?numberreject a buy that would take the position's cost above this many TAO
maxDailyLossTao?numberstop the run when equity falls this many TAO below the start of the UTC day
maxDrawdownPct?numberstop the run when equity falls this percentage below its peak
maxIntentsPerHour?numberreject new intents past this many in the last hour of blocks
minPoolTao?numberreject fills while the pool holds less than this many TAO
killSwitch?booleanreject every new intent

AlphaScript language v0.1 · runtime 0.2.0