Skip to content

Input Fields

Basic Information

With the input field commands you can create custom input fields for your scripts. The command will create an input field in the settings menu after the script is saved. Using input fields for dynamic values such as indicator parameters will make your life easier when adjusting or tuning the script.

Sorting

Inputs fields are not automatically sorted. They will be shown in the order of creation.

Tooltip

An input name should always be descriptive but brief. But sometimes you need a longer explanation for what the setting does. Each input command has a tooltip parameter which can be used to store and show additional information about the input. When this parameter is defined, you will see a circle with i appear next to your input field.

Grouping

Grouping input fields is a great way to have clear sections for configuration. You can do this in two ways.

  1. Define the group parameter for each input field (case-sensitive)

    local field1 = Input("Some Field", 0, {group = 'some group'})
    local field2 = Input("Other Field", 1, '', 'somE group')
    local field3 = Input("Another Field", 2, '', 'some Group')
    

  2. Use the InputGroupHeader() command and define groupless input fields after it (respects order of creation)

    InputGroupHeader('MA Settings')
    local length = Input('Length', 24, 'some tooltip')
    local maType = InputMaTypes('Type', SmaType)
    
    InputGroupHeader('Some other section')
    local field1 = Input('Some other field', 123)
    

Typical Inputs

Input()

The most used input field command will be Input(). This single command can create three types of input fields depending on the default value. The command supports numbers, text, and checkboxes. When there is no default value specified the default type will be a text field which can be used as a text or as a number input.

InputInterval()

Creates a drop-down list with all available interval options. Can be used for multi-interval strategies.

InputOrderType()

This creates a drop-down list with the available order types. The result can be used in combination with SetOrderType or the PlaceOrder* commands.

Account & Market

The InputAccount() command will create an account options drop-down. The return value is the account guid and can be used for every command containing an accountId or market parameter.

‌With InputMarket() you can create a market drop-down that is connected to the selected main account. The return value can be used for every command containing a market parameter.‌

InputAccountMarket() will create 2 drop-downs; one for a secondary account and the second for a market related to that account. The return value will be a concatenated string of the account ID, price source & market, and contract type (if derivatives/futures). This can be used for every command that contains an accountId or market parameter.

Price Source & Price Market

InputPriceSource() will create an options list with the available price sources (aka exchanges). With the return value and CreateMarket we can create a market for arbitrage or price index calculations, e.g. BTCUSDT on Binance and Huobi.

local mainSourceAndMarket = PriceMarket()
local priceSource = InputPriceSourceMarket('Other Exchange')
local secondSourceAndMarket = CreateMarket(priceSource)

InputPriceSourceMarket() will create both a price source (exchange) and market drop-down. The return value can be used for every command that requires or has an optional market parameter.

Options Drop-down

InputOptions ‌

Creates a drop-down with custom values.

local options = {'Uptrend', 'Downtrend', 'Sideways'}
local selected = InputOptions('Strategy', options[1], options)

‌InputConstant‌

Create an options drop-down based on the default value. All the commands belonging to the same category will be listed in the drop-down.

-- Dropdown with MA type enums
local maType = InputConstant('MA Type', SmaType)

-- Drowdown with position mode enums
local posMode = InputConstant('Position Mode', OneWayPositionMode)

Constant Helpers‌

There are also a few input commands that are designed for a specific category. Commands like InputMaTypes(), InputSignalTypes(), and InputCdlTypes() create a drop-down with all the options in that category.

Tables

HaasScript also supports tables as input fields. Although the support is limited to the script editor and only number fields are available, this type of input is perfect for settings like a market-making script or crypto index bot.

‌The command returns an array with the row values. By using a simple for-loop we can loop over the rows and collect the parameters.

‌The first parameter of the InputTable() should always be the InputTableOptions(). This is where we define the table specifications like the name, fixed number of rows, max number of rows and group. When the rows parameter is higher than 0, the table will have a fixed number of input rows that cannot be deleted or expanded. The maxRows defines the maximum rows you can expand to, if set to a higher than 0 value.

The rest of the parameters for InputTable() are the InputTableColumn() commands. This defines the column header and possibly (recommended) default values.