Input parameters
Input parameters provide a convenient way to change indicator’s algorithm parameters without the need of changing it’s
source code. For example, here is a simple indicator that calculates SMA with two parameters src
and length
:
After this indicator will be added to a chart, the values for the length
and source
parameters can be easily changed
in indicator’s Settings dialog:
How to add a parameter to an indicator
There are a few simple steps for adding an input parameter to indicator:
- Add one of the
@param.*
decorators (e.g.@param.int
) to theMain
entry point of the indicator. - Pass values for the two required arguments to the decorator:
id
— which is a string unique 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
andmin
. - Add a parameter to
Main
function (after theself
parameter) with the name which is equal to theid
of the parameter.
Available parameter types
Indie supports several types of input parameters, they are:
int
, created with decorator@param.int
bool
, created with decorator@param.bool
float
, created with decorator@param.float
str
, created with decorator@param.string
- source of type
SeriesF
, created with decorator@param.source
- time frame of type
TimeFrame
, created with decorator@param.time_frame
Was this page helpful?