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
:
# indie:lang_version = 4
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]
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:
There are a few simple steps for adding an input parameter to indicator:
@param.*
decorators (e.g. @param.int
) to the Main
entry point of the indicator.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.title
and min
.Main
function (after the self
parameter) with the name which is equal to the id
of the
parameter.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
SeriesF
, created with decorator @param.source
TimeFrame
, created with decorator @param.time_frame