Appearance
Script declaration
Every script starts with exactly one strategy() or indicator() call at the top level.
| Name | Description |
|---|---|
strategy() | Declares the script a strategy: it can trade. |
indicator() | Declares the script an indicator: it only draws. |
strategy()
ts
strategy(config: StrategyConfig): voidDeclares the script a strategy: it can trade. Call it exactly once, at the top level.
Types: StrategyConfig
indicator()
ts
indicator(config: IndicatorConfig): voidDeclares 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()).
| Field | Type | Description |
|---|---|---|
name | string | |
version? | "0.1" | |
market | Market | the subnet traded; on the AlphaForge chart the chart's subnet replaces it |
resolution | Resolution | bar 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? | ActOn | when event.onCandle fires (default "confirmed") |
calcOnEveryBlock? | boolean | also 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()).
| Field | Type | Description |
|---|---|---|
name | string | |
shortTitle? | string | legend title on the chart (e.g. "BB" for Bollinger Bands); defaults to name |
version? | "0.1" | |
overlay? | boolean | true: drawn on the price pane; false: in its own pane below the chart |
resolution? | Resolution | |
precision? | number | decimals 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.
| Field | Type | Description |
|---|---|---|
mode? | "quick" | "precise" | not read by the runtime; the Strategy tester's fill setting decides |
latencyBlocks? | number | blocks between intent creation and earliest fill (default 2) |
defaultToleranceBps? | number | default max/min price tolerance when an intent gives none (default 100) |
rateLimitBlocks? | number | stake rate limit between ops on one market (default from chain params) |
FeeConfig
Trading fees, in basis points of the TAO side.
| Field | Type | Description |
|---|---|---|
protocolBps? | number | the chain's protocol fee (default: the chain parameter) |
platformBps? | number | an 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.
| Field | Type | Description |
|---|---|---|
maxPriceImpactPct? | number | reject a fill whose price impact exceeds this percentage |
maxOrderTao? | number | reject a buy larger than this many TAO |
maxPositionTao? | number | reject a buy that would take the position's cost above this many TAO |
maxDailyLossTao? | number | stop the run when equity falls this many TAO below the start of the UTC day |
maxDrawdownPct? | number | stop the run when equity falls this percentage below its peak |
maxIntentsPerHour? | number | reject new intents past this many in the last hour of blocks |
minPoolTao? | number | reject fills while the pool holds less than this many TAO |
killSwitch? | boolean | reject every new intent |
