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:
# indie:lang_version = 5
from indie import indicator, param, source
from indie.algorithms import Sma

@indicator('Example')
@param.source('src', default=source.CLOSE, title='Source')
@param.int('length', default=12, min=1, title='Length')
def Main(self, src, length):
    sma = Sma.new(src, length)
    return sma[0]
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: