Skip to main content
Input parameters provide a convenient way to change indicator’s algorithm parameters without the need to change its source code. For example, here is a simple indicator that calculates SMA with two parameters src and length:
Once this indicator is added to a chart, the values for the length and source parameters can be easily changed in the indicator’s Settings dialog: Figure 7.1. The Settings dialog of indicator.

How to add a parameter to an indicator

There are a few simple steps for adding an input parameter to an indicator:
  • Add one of the @param.* decorators (e.g. @param.int) to the Main entry point of the indicator.
  • Pass values for the two required arguments to the decorator:
    • id — which is unique string identifier of the parameter (the very first argument of any @param.* decorator),
    • default — which is a default value of the parameter.
  • Pass values to optional arguments of the decorator if needed (this depends on the decorator type, they could differ). In the example above there are optional arguments title and min.
  • Add a parameter to the Main function (after the self parameter) with the name matching the id of the parameter.

Available parameter types

Indie supports several types of input parameters, they are:

Grouping parameters

Every @param.* decorator takes an optional group keyword. Parameters that share the same group string are shown together under a section header in the Settings dialog:

Adding a help tooltip

Every @param.* decorator takes an optional tooltip keyword. When it is set, the Settings dialog shows an info icon right after the parameter’s title, and hovering it shows the text. Use it to explain what the parameter does or how its options differ, without making the title long:
The text must be a non-empty single line of at most 512 characters. A parameter without a tooltip shows no icon.

Showing a parameter only when it applies

Every @param.* decorator takes an optional show_if keyword. The parameter then appears in the Settings dialog only while the condition holds, which keeps the dialog short: show a few inputs by default and reveal the advanced ones when the user asks for them. A common pattern is a Preset select with a Custom option that reveals the inputs the presets set:
With the default preset the dialog shows only Preset. Choosing Custom reveals Length, Width and Smooth the basis, and turning on Smooth the basis reveals Smoothing length.

Condition forms

Option names are written without quotes inside the condition. To reuse a condition on several parameters, put it in a module-level constant, for example CUSTOM = 'preset == Custom', and pass show_if=CUSTOM. Conditions chain: a parameter is shown only if its own condition holds and the parameter it refers to is shown. In the example, Smoothing length refers to smooth, so it stays hidden under the Standard and Wide presets even if Smooth the basis was turned on earlier.
A hidden parameter keeps its value and is still passed to Main. Hiding it does not reset it to the default. If a preset should override the hidden inputs, Main has to do it, as the example does for Standard and Wide. Otherwise values the user set under Custom keep affecting the result after switching back to another preset.

Compilation errors

The compiler checks every condition. It reports an error if the condition:
  • refers to a parameter that does not exist, or to the parameter itself;
  • creates a cycle, for example a depends on b and b depends on a;
  • uses the 'flag' or 'not flag' form with a parameter that is not a @param.bool;
  • uses == or != with a parameter that is not a @param.str with options, or with a value that is not one of its options;
  • uses != in a way that excludes every option, so the parameter could never be shown;
  • uses a word of the condition syntax, such as not, as a parameter id;
  • is empty or longer than 256 characters.