STS Script¶
STS Script is a lightweight scripting language for the trading terminal.
It is used to build:
- custom chart indicators;
- automated trading robots;
- simple signals;
- chart lines and visual series;
- controlled calls to terminal functions.
STS Script is intentionally smaller than Pine Script or MQL. Scripts run through the platform runtime and can only access APIs explicitly exposed by the terminal.
Core Idea¶
Every user script is stored as one script entity, but the kind field defines its runtime capabilities.
| Kind | Purpose | Trading access |
|---|---|---|
indicator |
Calculates series and draws custom chart indicators | No |
robot |
Runs automated trading logic | Yes, through trade.* |
strategy |
Reserved for backtesting/simulation | Not implemented in MVP |
widget |
Reserved for custom UI widgets | Not implemented in MVP |
The script language is stored as stscript.
Storage Model¶
Scripts are stored through the Script REST API.
{
"id": 42,
"login": 1001,
"name": "My MA Robot",
"script": "input length = 20",
"description": "Simple example",
"kind": "robot",
"language": "stscript",
"visibility": "private",
"autostart": 0,
"enabled": 1,
"created_time": 1777196331,
"updated_time": 1777196331
}
Visibility:
private- visible only to the script owner;public- reserved for future publishing/sharing flows.
In the first MVP all scripts created from the terminal are saved as private.
The terminal UI does not expose a public/private selector yet; public stays in the API contract for future publishing flows.
Lifecycle flags:
enabled: 0 | 1controls whether the script is available;autostart: 0 | 1controls whether the platform starts/registers it after application load.
Runtime state such as running, logs, calculated series, and worker state is client-side session state and is not the source of truth in the backend.
Basic Syntax¶
STS Script is line-oriented. Statements do not require semicolons.
The desktop editor registers a dedicated Monaco language named stscript. It highlights STS keywords, event blocks, technical analysis functions, trade functions, built-in series, strings, and numbers.
script("Moving Average", kind="indicator")
input length = 20
ma = ta.sma(close, length)
plot(ma, title="MA", color="#2962FF", width=2)
Script Declaration¶
Every STS Script source must start with a script(...) declaration.
script("MA Crossover", kind="robot")
Rules:
- the declaration must be the first statement in the file;
- the first positional argument is the script title;
kindis required;- supported MVP kinds are
indicatorandrobot.
The platform extracts backend name and kind from this declaration when saving or running the script.
Inputs¶
Inputs define user-configurable constants.
input length = 20
input volume = 0.01
input timeFrame = 300
Common robot inputs:
| Input | Meaning |
|---|---|
timeFrame |
Candle frame in seconds, for example 300 for 5 minutes |
historyCount |
Number of historical candles requested before runtime start |
volume |
Trade volume |
dryRun |
1 simulates trade actions, 0 sends real trade requests |
maxPositions |
Maximum open positions per symbol for the current robot |
cooldownSeconds |
Minimum delay between open trade actions |
maxActionsPerEvent |
Maximum number of trade actions processed from one event |
Series¶
Series are calculated for every candle.
fast = ta.sma(close, 9)
slow = ta.sma(close, 21)
Built-in candle series:
openhighlowclosevolumebidask
For historical candles, bid and ask fall back to close. During live quote processing they are updated from the live feed.
History Access¶
Use [n] to access previous values.
previousClose = close[1]
previousFast = fast[1]
Conditions¶
if close > fast and close[1] <= fast[1] {
signal = 1
}
Supported logical operators:
andornot