BarSpec v1

Forge API 1

Fields

NameTypeRequired
symbolstringRequired
bar_typetime | heikin_ashi | renko | range | kagi | point_figure | line_break | tick | countRequired
paramsobjectRequired
basisbid | ask | mid | last | quoteOptional
day_boundarystringOptional
on_closurecontinue_grid | resetOptional
anchorone of severalOptional

timeframe

price_amount

NameTypeRequired
pricenumberOptional
pointsnumberOptional
pipsnumberOptional
ticksnumberOptional

box_size

Schema

json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "BarSpec v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "symbol",
    "bar_type",
    "params"
  ],
  "properties": {
    "symbol": {
      "type": "string",
      "pattern": "^[A-Z0-9._#-]{1,40}$"
    },
    "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",
      "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9] [A-Za-z_]+(/[A-Za-z_+-]+)*$"
    },
    "on_closure": {
      "enum": [
        "continue_grid",
        "reset"
      ]
    },
    "anchor": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind"
          ],
          "properties": {
            "kind": {
              "enum": [
                "price_multiple",
                "history_start"
              ]
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "price"
          ],
          "properties": {
            "kind": {
              "const": "fixed"
            },
            "price": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          }
        }
      ]
    }
  },
  "$defs": {
    "timeframe": {
      "type": "string",
      "pattern": "^(M[1-9][0-9]*|H[1-9][0-9]*|D[1-9][0-9]*|W1|MN1)$"
    },
    "price_amount": {
      "type": "object",
      "minProperties": 1,
      "maxProperties": 1,
      "additionalProperties": false,
      "properties": {
        "price": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "points": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "pips": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "ticks": {
          "type": "number",
          "exclusiveMinimum": 0
        }
      }
    },
    "box_size": {
      "oneOf": [
        {
          "$ref": "#/$defs/price_amount"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "method",
            "period"
          ],
          "properties": {
            "method": {
              "const": "atr"
            },
            "period": {
              "type": "integer",
              "minimum": 1
            },
            "mult": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "timeframe": {
              "$ref": "#/$defs/timeframe"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "method",
            "value"
          ],
          "properties": {
            "method": {
              "const": "percent"
            },
            "value": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "method"
          ],
          "properties": {
            "method": {
              "const": "traditional"
            }
          }
        }
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "time"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "timeframe"
            ],
            "properties": {
              "timeframe": {
                "$ref": "#/$defs/timeframe"
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "heikin_ashi"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "timeframe"
            ],
            "properties": {
              "timeframe": {
                "$ref": "#/$defs/timeframe"
              },
              "seed": {
                "enum": [
                  "mt5_raw",
                  "textbook"
                ]
              },
              "settle_bars": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "renko"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "box"
            ],
            "properties": {
              "box": {
                "$ref": "#/$defs/box_size"
              },
              "trend": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "reversal": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "offset": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "wicks": {
                "type": "boolean"
              },
              "new_bar_mode": {
                "type": "string"
              },
              "preset": {
                "enum": [
                  "traditional",
                  "median",
                  "unirenko",
                  "reversal_size",
                  null
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "range"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "size"
            ],
            "properties": {
              "size": {
                "$ref": "#/$defs/price_amount"
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "kagi"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "reversal"
            ],
            "properties": {
              "reversal": {
                "$ref": "#/$defs/box_size"
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "point_figure"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "box"
            ],
            "properties": {
              "box": {
                "$ref": "#/$defs/box_size"
              },
              "reversal": {
                "type": "integer",
                "minimum": 1
              },
              "one_box": {
                "type": "boolean"
              },
              "event": {
                "enum": [
                  "column",
                  "box"
                ]
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "line_break"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "lines": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "tick"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "n"
            ],
            "properties": {
              "n": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "bar_type": {
            "const": "count"
          }
        }
      },
      "then": {
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "n",
              "of"
            ],
            "properties": {
              "n": {
                "type": "integer",
                "minimum": 1
              },
              "of": {
                "$ref": "#/$defs/timeframe"
              }
            }
          }
        }
      }
    }
  ]
}