Appearance
Validate
Compiles a dxScript source file, executes it on a synthetic candle snapshot, and returns declared metadata or a structured error.
Service: dxscript.indicators.v1.IndicatorService
Method: validate
Interaction: request / response
HTTP
http
POST /dxscript.indicators.v1.indicatorservice/validate
Content-Type: application/jsonRequest
| Field | Type | Required | Description |
|---|---|---|---|
lang | string | yes | Must be dxscript-js |
content | string | yes | Full script source |
Examples
Indicator validation (success)
bash
curl -sS -X POST 'https://dxlink-dxscript-http-demo.dxkube.com/dxscript.indicators.v1.indicatorservice/validate' \
-H 'Content-Type: application/json' \
-d '{
"lang": "dxscript-js",
"content": "const n = input.double(\"length\", 14);\nfunction onTick() {\n output(\"rsi\", ta.rsi(close, n));\n spline(ta.rsi(close, n), {title: \"RSI\"});\n}"
}'Request body:
json
{
"lang": "dxscript-js",
"content": "const n = input.double(\"length\", 14);\nfunction onTick() {\n output(\"rsi\", ta.rsi(close, n));\n spline(ta.rsi(close, n), {title: \"RSI\"});\n}"
}Response 200 — error is absent:
json
{
"inParameters": [
{
"name": "length",
"type": "INPUT_TYPE_DOUBLE",
"doubleParam": {
"defaultValue": 14.0
}
}
],
"outputs": [
{ "name": "rsi" }
],
"splines": [
{
"id": 0,
"title": "RSI",
"style": "LINE",
"offset": 0,
"overlay": true
}
],
"compilationTime": "0.006493433s",
"executionTime": "0.018204370s",
"executionTotalTicks": 1000,
"calculationResult": {
"output": {
"rsi": {
"values": ["NaN"]
}
},
"spline": {
"0": {
"value": "NaN",
"style": "LINE",
"offset": 0,
"title": "RSI",
"overlay": true
}
}
}
}Empty layer lists (backgroundColors, barColors, shapes) are omitted. Timing and executionTotalTicks depend on server configuration (snapshotSize was 1000 on this stand).
First-bar samples reflect the synthetic snapshot only. Each output channel is { "values": [value] } with at most one entry. RSI returns "NaN" on the first bar when the lookback is not satisfied yet — that is still a successful validation. Non-finite doubles serialize as JSON strings ("NaN", "Infinity", "-Infinity"), not null.
Validation error (runtime)
bash
curl -sS -X POST 'https://dxlink-dxscript-http-demo.dxkube.com/dxscript.indicators.v1.indicatorservice/validate' \
-H 'Content-Type: application/json' \
-d '{
"lang": "dxscript-js",
"content": "function onTick() {\n spline(undefinedSeries, {title: \"Broken\"});\n}"
}'Response 200 — error is set; calculationResult and timing fields are absent:
json
{
"error": {
"id": "8104ca8b-e57c-405d-b6b8-37de865bf143",
"type": "RUNTIME",
"scriptName": "test_validate",
"startLine": 2,
"startColumn": 10,
"endLine": 2,
"endColumn": 24,
"message": "undefinedSeries is not defined",
"scriptStack": [
{ "functionName": "onTick", "line": 2, "column": 10 }
]
}
}Validation error (syntax)
bash
curl -sS -X POST 'https://dxlink-dxscript-http-demo.dxkube.com/dxscript.indicators.v1.indicatorservice/validate' \
-H 'Content-Type: application/json' \
-d '{
"lang": "dxscript-js",
"content": "const x = ;"
}'Response 200:
json
{
"error": {
"id": "8a3caf2c-f629-4884-a60c-8821335bbd53",
"type": "SYNTAX",
"scriptName": "test_validate",
"startLine": 1,
"startColumn": 11,
"endLine": 1,
"endColumn": 11,
"message": "Expected an operand but found ;"
}
}On failure, error is the only payload field. scriptStack is omitted when empty. scriptName is assigned by the server.
Response fields
| Field | Type | Description |
|---|---|---|
inParameters | array | Declared input() parameters with typed defaults |
outputs | array | { name } entries from output() |
splines | array | Spline layer metadata (id, title, style, offset, overlay) |
backgroundColors | array | bgColor() layer metadata; omitted when empty |
barColors | array | barColor() layer metadata; omitted when empty |
shapes | array | shape() layer metadata; omitted when empty |
meta | object | title, shortTitle when declared by indicator() or strategy() |
compilationTime | string | Duration (e.g. "0.240804875s"); present on success only |
executionTime | string | Wall-clock script execution duration; present on success only |
executionTotalTicks | int | Number of candles the script ran over; present on success only |
calculationResult | object | First-bar samples (see below); present on success only |
strategyAnalytics | object | Performance summary of a strategy() run (performance only); omitted for non-strategy scripts |
error | object | Structured script error; present on failure only |
inParameters types
Each parameter has name, type, and exactly one typed payload:
type | Payload field | Description |
|---|---|---|
INPUT_TYPE_BOOL | boolParam | { defaultValue } |
INPUT_TYPE_DOUBLE | doubleParam | { defaultValue, min?, max?, step?, options? } |
INPUT_TYPE_STRING | stringParam | { defaultValue, options? } |
INPUT_TYPE_SOURCE | sourceParam | { defaultValue, options? } |
INPUT_TYPE_COLOR | colorParam | { defaultValue, defaultAlpha? } |
INPUT_TYPE_SESSION | sessionParam | { defaultValue, options?, value, timeZone? } |
INPUT_TYPE_ENUM | enumParam | { defaultValue, options? } |
calculationResult
First-bar samples only, one value per series or layer:
| Channel | Map key | Value shape |
|---|---|---|
output | output channel name | { values: [value] } — first bar only (at most one entry); empty values when there is no sample. Numbers or non-finite strings ("NaN", "Infinity", "-Infinity") |
spline | layer id ("0", "1", …) | Spline knot with value (number or "NaN" string), optional color, style, offset, title, overlay |
backgroundColor | layer name | { color, offset?, title?, numberOfLast?, overlay } |
barColor | layer name | { color, offset?, title?, numberOfLast? } |
shape | series name | { value, color?, textColor?, text?, shapeStyle?, offset?, title?, location?, overlay? } |
Unset channels are omitted from calculationResult. Colors use { "value": "<hex or palette name>", "alpha"?: number }.
WebSocket RPC
Call validate on service dxscript.indicators.v1.IndicatorService through the dxLink WebSocket session using the same ValidateRequest / ValidateResponse protobuf messages. JSON field names match the HTTP mapping.
Strategy scripts
Strategy support can be disabled on a deployment. In that case, scripts that call strategy() fail validation at compile time.
For a strategy script the response also carries the run's performance summary in strategyAnalytics.performance, in the shape the backtest response uses. It is present for every strategy run, including one that traded nothing. The rest of what a backtest returns — equitySeries, barCloseSeries, fills, trades and orders — is left out, as calculationResult is cut to first-bar samples: one value per bar would make up most of the response and describe nothing real.
The candles are generated, not market data. The summary shows that the strategy compiled and ran; its numbers describe the synthetic series and say nothing about any instrument. Use Backtest for a run over real candles.
See also
- Validator service
- Indicator —
indicator()declaration - Strategy —
strategy()declaration