Hull Moving Average (HMA)

Hull Moving Average #

The hma tool calculates the Hull Moving Average (HMA) indicator’s value and compares it to the target value that is specified in the configuration.

More information about the Hull Moving Average indicator:

The hma tool can be backtested. More information about strategy backtesting can be found here.

Configuration #

{
	"type": "hma",
	"context_id": "hma-id-123",
	"description": "a simple tool",
	"field": "close",
	"length": 20,
	"offset": 1,
	"condition": {
		"type": "constant",
		"target": "20.5",
		"operator": "equal"
	}
}
  • type - string
    The type of the tool configuration.

    Tool configuration types are described in detail here.

  • context_id - string (optional; default: unused)
    The ID of the tool that is used when inserting data into the context store.

    The context data store and its IDs are described in detail here.

  • description - string (optional; default: unused)
    The description of the tool and its purpose.

  • field - string (enum)
    The field of each selected candle that is used when calculating the indicator’s value. Possible values:

    • open
      The opening price of a candle’s period.

    • high
      The highest price of a candle’s period.

    • low
      The lowest price of a candle’s period.

    • close
      The closing price of a candle’s period.

    • volume
      The trading volume of a candle’s period.

    • typical-price
      The typical price of a candle’s period, it is calculated as follows: (High + Low + Close) / 3.

  • length - unsigned int
    The number that determines how many data points are used when calculating the indicator’s value. It must be greater than 0.

  • offset - unsigned int (optional; default: 0)
    The number that determines how many candles are skipped until the first candle is selected. Note that the candles are ordered from the latest to the oldest, which means that if the offset is set to zero, the latest candle is used as the first one.

  • condition - object
    The condition that is used when checking the indicator’s value.

    • type - string (enum)
      The type of the condition that determines what additional properties are required and how the target value is formed. Possible types are as follows:

      • constant
        When this type is active, the target value that is specified in the configuration is used as the condition’s target value. The additional properties of this type are the following:

        • target - string (decimal)
          The target value that is used without any additional processing. It cannot be less than 0.
      • candle
        When this type is active, the target value is formed from one of the candle fields. The additional properties of this type are the following:

        • field - string (enum)
          The field of the condition’s candle that is used when forming the target value. Possible values:

          • open
            The opening price of the candle’s period.

          • high
            The highest price of the candle’s period.

          • low
            The lowest price of the candle’s period.

          • close
            The closing price of the candle’s period.

          • volume
            The trading volume of the candle’s period.

          • typical-price
            The typical price of the candle’s period, it is calculated as follows: (High + Low + Close) / 3.

        • offset - unsigned int (optional; default: 0)
          The number that determines how many candles are skipped until the condition’s candle is selected. Note that the candles are ordered from the latest to the oldest, which means that if the offset is set to zero, the latest candle is selected.

        • multiply - boolean (optional; default: false)
          The property that determines whether the condition candle’s value is multiplied or increased/decreased by the change value.

        • change - string (decimal)
          The number that is used to modify the condition candle’s value. If multiply is active, this number cannot be less than 0.

      • ticker
        When this type is active, the target value is formed from one of the ticker fields. The additional properties of this type are the following:

        • field - string (enum)
          The field of the condition’s ticker that is used when forming the target value. Possible values:

          • ask
            The latest ask price.

          • bid
            The latest bid price.

          • last
            The latest trade’s price.

          • volume
            The 24 hour trading volume.

        • multiply - boolean (optional; default: false)
          The property that determines whether the condition ticker’s value is multiplied or increased/decreased by the change value.

        • change - string (decimal)
          The number that is used to modify the condition ticker’s value. If multiply is active, this number cannot be less than 0.

    • operator - string (enum)
      The operator that is used when comparing the indicator’s value to the condition’s target value. Possible values:

      • equal, eq, ==
        The equality operator checks if the indicator’s value is equal to the condition’s target value.

      • greater-than, gt, >
        The greater than operator checks if the indicator’s value is greater than the condition’s target value.

      • less-than, lt, <
        The less than operator checks if the indicator’s value is less than the condition’s target value.

      • greater-than-or-equal, ge, >=
        The greater than or equal operator checks if the indicator’s value is greater than or equal to the condition’s target value.

      • less-than-or-equal, le, <=
        The less than or equal operator checks if the indicator’s value is less than or equal to the condition’s target value.

      • not-equal, ne, !=
        The inequality operator checks if the indicator’s value is not equal to the condition’s target value.

Report #

{
	"type": "hma",
	"permit": true,
	"value": "20.5",
	"condition": {
		"type": "constant",
		"result": true
	}
}
  • type - string
    The type of the tool report.

    Tool report types are described in detail here.

  • permit - boolean
    The property that determines whether the tool gave its permission to continue strategy execution or not.

    The tool execution flow is described in detail here.

  • value - string (decimal)
    The indicator’s value that was calculated from the candle data and compared to the condition’s target value.

  • condition - object
    The report of the condition that was used when checking the indicator’s value.

    • type - string (enum)
      The type of the condition that determines what additional properties are included in the report. The types and their properties are as follows:

      • constant
        When this type is processed, no additional properties are added.

      • candle
        When this type is processed, the following properties are added:

        • value - string (decimal)
          The value that was extracted from the candle when forming the condition’s target value.

        • target - string (decimal)
          The value that was used as the condition’s target value.

      • ticker
        When this type is processed, the following properties are added:

        • value - string (decimal)
          The value that was extracted from the ticker when forming the condition’s target value.

        • target - string (decimal)
          The value that was used as the condition’s target value.

    • result - boolean
      The property that determines whether the comparison was successful or not.

If an error occurs during the hma tool’s execution, only type and error properties are added to the report. The error property is described in detail here.

Context #

The objects that the hma tool inserts into the context store are as follows:

  • tools.<context-id>.permit - boolean
    The object that determines whether the tool gave its permission to continue strategy execution or not.

  • tools.<context-id>.value - string (decimal)
    The indicator’s value that was calculated from the candle data and compared to the condition’s target value.

  • tools.<context-id>.condition - map
    The results of the condition that was used when checking the indicator’s value.

    • The type of the condition determines what additional objects are inserted into the context store. The types and their objects are as follows:

      • constant
        When this type is processed, no additional objects are inserted into the context store.

      • candle
        When this type is processed, the following objects are inserted into the context store:

        • tools.<context-id>.condition.value - string (decimal)
          The value that was extracted from the candle when forming the condition’s target value.

        • tools.<context-id>.condition.target - string (decimal)
          The value that was used as the condition’s target value.

      • ticker
        When this type is processed, the following objects are inserted into the context store:

        • tools.<context-id>.condition.value - string (decimal)
          The value that was extracted from the ticker when forming the condition’s target value.

        • tools.<context-id>.condition.target - string (decimal)
          The value that was used as the condition’s target value.

    • tools.<context-id>.condition.result - boolean
      The object that determines whether the comparison of the indicator’s value and the condition’s target value was successful or not.

If an error occurs during the hma tool’s execution, only the tools.<context-id>.error object is inserted into the context store. This context data object is described in detail here.