Strategy Spec v1
Forge API 1
Fields
| Name | Type | Required |
|---|---|---|
| forge_api | any | Required |
| kind | any | Required |
| name | string | Required |
| bars | bars | Required |
| symbols | array | Required |
| direction | long | short | both | Required |
| params | array | Required |
| constraints | array | Required |
| entries | object | Required |
| exits | object | Required |
| stop | kinded_or_null | Required |
| target | kinded_or_null | Required |
| trail | kinded_or_null | Required |
| size | kinded | Required |
| filters | array | Required |
| prop | kinded_or_null | Required |
| meta | object | Required |
bars
| Name | Type | Required |
|---|---|---|
| bar_type | time | heikin_ashi | renko | range | kagi | point_figure | line_break | tick | count | Required |
| params | object | Required |
| basis | bid | ask | mid | last | quote | Optional |
| day_boundary | string | Optional |
| on_closure | continue_grid | reset | Optional |
| anchor | object or null | Optional |
param
| Name | Type | Required |
|---|---|---|
| name | string | Required |
| type | int | float | decimal | bool | choice | enum | timeframe | symbol | session | time | price | source | ma_method | volume | color | text | Required |
| default | any | Required |
| min | number | Optional |
| max | number | Optional |
| step | number | Optional |
| places | integer | Optional |
| options | array | Optional |
| values | array | Optional |
| scale | linear | log | Optional |
| optimize | boolean | Optional |
| space | entry | exit | stop | size | filter | Optional |
| group | string | Optional |
| label | string | Optional |
| help | string | Optional |
| order | integer | Optional |
| inline | string | Optional |
| tz | string | Optional |
Schema
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Strategy Spec v1",
"type": "object",
"additionalProperties": false,
"required": [
"forge_api",
"kind",
"name",
"bars",
"symbols",
"direction",
"params",
"constraints",
"entries",
"exits",
"stop",
"target",
"trail",
"size",
"filters",
"prop",
"meta"
],
"properties": {
"forge_api": {
"const": 1
},
"kind": {
"const": "strategy_spec"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"bars": {
"$ref": "#/$defs/bars"
},
"symbols": {
"type": "array",
"minItems": 1,
"maxItems": 50,
"items": {
"type": "string",
"pattern": "^[A-Z0-9._#-]{1,40}$"
}
},
"direction": {
"enum": [
"long",
"short",
"both"
]
},
"params": {
"type": "array",
"maxItems": 100,
"items": {
"$ref": "#/$defs/param"
}
},
"constraints": {
"type": "array",
"items": {
"$ref": "#/$defs/cond"
}
},
"entries": {
"type": "object",
"additionalProperties": false,
"required": [
"long",
"short"
],
"properties": {
"long": {
"$ref": "#/$defs/cond_or_null"
},
"short": {
"$ref": "#/$defs/cond_or_null"
}
}
},
"exits": {
"type": "object",
"additionalProperties": false,
"required": [
"long",
"short",
"exit_on_invalid"
],
"properties": {
"long": {
"$ref": "#/$defs/cond_or_null"
},
"short": {
"$ref": "#/$defs/cond_or_null"
},
"exit_on_invalid": {
"type": "boolean"
}
}
},
"stop": {
"$ref": "#/$defs/kinded_or_null"
},
"target": {
"$ref": "#/$defs/kinded_or_null"
},
"trail": {
"$ref": "#/$defs/kinded_or_null"
},
"size": {
"$ref": "#/$defs/kinded"
},
"filters": {
"type": "array",
"items": {
"$ref": "#/$defs/kinded"
}
},
"prop": {
"$ref": "#/$defs/kinded_or_null"
},
"meta": {
"type": "object",
"additionalProperties": false,
"properties": {
"description": {
"type": "string",
"maxLength": 4000
},
"tags": {
"type": "array",
"maxItems": 20,
"items": {
"type": "string",
"maxLength": 40
}
}
}
}
},
"$defs": {
"bars": {
"type": "object",
"additionalProperties": false,
"required": [
"bar_type",
"params"
],
"properties": {
"bar_type": {
"enum": [
"time",
"heikin_ashi",
"renko",
"range",
"kagi",
"point_figure",
"line_break",
"tick",
"count"
]
},
"params": {
"type": "object"
},
"basis": {
"enum": [
"bid",
"ask",
"mid",
"last",
"quote"
]
},
"day_boundary": {
"type": "string"
},
"on_closure": {
"enum": [
"continue_grid",
"reset"
]
},
"anchor": {
"type": [
"object",
"null"
]
}
}
},
"param": {
"type": "object",
"additionalProperties": false,
"required": [
"name",
"type",
"default"
],
"properties": {
"name": {
"type": "string",
"pattern": "^[a-z][a-z0-9_]{0,39}$"
},
"type": {
"enum": [
"int",
"float",
"decimal",
"bool",
"choice",
"enum",
"timeframe",
"symbol",
"session",
"time",
"price",
"source",
"ma_method",
"volume",
"color",
"text"
]
},
"default": {},
"min": {
"type": "number"
},
"max": {
"type": "number"
},
"step": {
"type": "number",
"exclusiveMinimum": 0
},
"places": {
"type": "integer",
"minimum": 0,
"maximum": 10
},
"options": {
"type": "array"
},
"values": {
"type": "array"
},
"scale": {
"enum": [
"linear",
"log"
]
},
"optimize": {
"type": "boolean"
},
"space": {
"enum": [
"entry",
"exit",
"stop",
"size",
"filter"
]
},
"group": {
"type": "string",
"maxLength": 40
},
"label": {
"type": "string",
"maxLength": 60
},
"help": {
"type": "string",
"maxLength": 200
},
"order": {
"type": "integer"
},
"inline": {
"type": "string",
"maxLength": 40
},
"tz": {
"type": "string",
"maxLength": 64
}
}
},
"kinded": {
"type": "object",
"required": [
"kind"
],
"properties": {
"kind": {
"type": "string",
"pattern": "^[a-z][a-z0-9_]*$"
}
}
},
"kinded_or_null": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/kinded"
}
]
},
"cond_or_null": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/cond"
}
]
},
"name": {
"type": "string",
"maxLength": 60
},
"cond": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"all"
],
"properties": {
"all": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/$defs/cond"
}
},
"name": {
"$ref": "#/$defs/name"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"any"
],
"properties": {
"any": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/$defs/cond"
}
},
"name": {
"$ref": "#/$defs/name"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"not"
],
"properties": {
"not": {
"$ref": "#/$defs/cond"
},
"name": {
"$ref": "#/$defs/name"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"compare"
],
"properties": {
"name": {
"$ref": "#/$defs/name"
},
"compare": {
"type": "object",
"additionalProperties": false,
"required": [
"left",
"op",
"right"
],
"properties": {
"left": {
"$ref": "#/$defs/operand"
},
"op": {
"enum": [
"<",
"<=",
">",
">=",
"==",
"!="
]
},
"right": {
"$ref": "#/$defs/operand"
}
}
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"cross"
],
"properties": {
"name": {
"$ref": "#/$defs/name"
},
"cross": {
"type": "object",
"additionalProperties": false,
"required": [
"a",
"dir",
"b"
],
"properties": {
"a": {
"$ref": "#/$defs/operand"
},
"dir": {
"enum": [
"over",
"under"
]
},
"b": {
"$ref": "#/$defs/operand"
}
}
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"state"
],
"properties": {
"state": {
"$ref": "#/$defs/operand"
},
"name": {
"$ref": "#/$defs/name"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"event"
],
"properties": {
"name": {
"$ref": "#/$defs/name"
},
"event": {
"type": "object",
"additionalProperties": false,
"required": [
"of",
"value"
],
"properties": {
"of": {
"$ref": "#/$defs/operand"
},
"value": {
"enum": [
1,
-1
]
}
}
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"zone"
],
"properties": {
"name": {
"$ref": "#/$defs/name"
},
"zone": {
"type": "object",
"additionalProperties": false,
"required": [
"of",
"where"
],
"properties": {
"of": {
"$ref": "#/$defs/ind_ref"
},
"out": {
"type": "string"
},
"where": {
"enum": [
"inside",
"above",
"below"
]
}
}
}
}
}
]
},
"operand": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"price"
],
"properties": {
"price": {
"enum": [
"open",
"high",
"low",
"close",
"hl2",
"hlc3",
"ohlc4",
"hlcc4"
]
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"const"
],
"properties": {
"const": {
"type": "number"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"param"
],
"properties": {
"param": {
"type": "string",
"pattern": "^[a-z][a-z0-9_]{0,39}$"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"ind",
"out"
],
"properties": {
"ind": {
"$ref": "#/$defs/ind_ref"
},
"out": {
"type": "string",
"minLength": 1
},
"ago": {
"type": "integer",
"minimum": 0
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"tf",
"of"
],
"properties": {
"tf": {
"type": "string",
"pattern": "^(M[1-9][0-9]*|H[1-9][0-9]*|D[1-9][0-9]*|W1|MN1)$"
},
"of": {
"$ref": "#/$defs/operand"
}
}
}
]
},
"ind_ref": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"builtin",
"inputs"
],
"properties": {
"builtin": {
"type": "string",
"pattern": "^[a-z][a-z0-9_]*$"
},
"inputs": {
"type": "object"
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"custom",
"version",
"inputs"
],
"properties": {
"custom": {
"type": "string",
"minLength": 1
},
"version": {
"type": "integer",
"minimum": 1
},
"inputs": {
"type": "object"
}
}
}
]
}
}
}