indie
Algorithm.__init__()
Color.__call__()
Context.calc_on()
Context.new_mut_series_f()
Fill.__init__()
IndieError.__init__()
MutSeries[T].__setitem__()
MutSeries[T].calc()
MutSeries[T].new()
Optional[T].__bool__()
Optional[T].value()
Optional[T].value_or()
Plot.__init__()
Series[T].__getitem__()
Series[T].__len__()
Series[T].get()
Series[T].request_size()
TimeFrame.to_minutes()
tf()
Algorithm.ctx
Context.bar_count
Context.bar_index
Context.close
Context.high
Context.hl2
Context.hlc3
Context.info
Context.is_last_bar
Context.is_last_history_bar
Context.is_realtime
Context.low
Context.ohlc4
Context.open
Context.time
Context.time_frame
Context.volume
SymbolInfo.exchange_aliases
SymbolInfo.exchange_code
SymbolInfo.marketdata_timezone
SymbolInfo.price_precision
SymbolInfo.tick_size
SymbolInfo.ticker
format.INHERITED
format.PRICE
format.VOLUME
line_style.DASHED
line_style.DOTTED
line_style.SOLID
plot_style.COLUMNS
plot_style.HISTOGRAM
plot_style.LINE
plot_style.STEPS
source.CLOSE
source.HIGH
source.HL2
source.HLC3
source.LOW
source.OHLC4
source.OPEN
source.VOLUME
indie.algorithms
Adx.__init__()
Adx.calc()
Adx.new()
Atr.__init__()
Atr.calc()
Atr.new()
Bb.__init__()
Bb.calc()
Bb.new()
Cci.__init__()
Cci.calc()
Cci.new()
Change.__init__()
Change.calc()
Change.new()
CumSum.__init__()
CumSum.calc()
CumSum.new()
Dev.__init__()
Dev.calc()
Dev.new()
Donchian.__init__()
Donchian.calc()
Donchian.new()
Ema.__init__()
Ema.calc()
Ema.new()
FixNan.__init__()
FixNan.calc()
FixNan.new()
Highest.__init__()
Highest.calc()
Highest.new()
Lowest.__init__()
Lowest.calc()
Lowest.new()
Ma.__init__()
Ma.calc()
Ma.new()
Median.__init__()
Median.calc()
Median.new()
Mfv.__init__()
Mfv.calc()
Mfv.new()
NanToZero.__init__()
NanToZero.calc()
NanToZero.new()
NetVolume.__init__()
NetVolume.calc()
NetVolume.new()
PercentRank.__init__()
PercentRank.calc()
PercentRank.new()
Rma.__init__()
Rma.calc()
Rma.new()
Roc.__init__()
Roc.calc()
Roc.new()
Rsi.__init__()
Rsi.calc()
Rsi.new()
SinceHighest.__init__()
SinceHighest.calc()
SinceHighest.new()
SinceLowest.__init__()
SinceLowest.calc()
SinceLowest.new()
Sma.__init__()
Sma.calc()
Sma.new()
StdDev.__init__()
StdDev.calc()
StdDev.new()
Stoch.__init__()
Stoch.calc()
Stoch.new()
Sum.__init__()
Sum.calc()
Sum.new()
Supertrend.__init__()
Supertrend.calc()
Supertrend.new()
Tr.__init__()
Tr.calc()
Tr.new()
Tsi.__init__()
Tsi.calc()
Tsi.new()
Vwap.__init__()
Vwap.calc()
Vwap.new()
Vwma.__init__()
Vwma.calc()
Vwma.new()
Wma.__init__()
Wma.calc()
Wma.new()
indie.color
math
statistics
datetime
NoneType.__bool__()
abs()
bool.__bool__()
bool.__init__()
float.__bool__()
float.__init__()
int.__bool__()
int.__init__()
len()
list[T].__getitem__()
list[T].__len__()
list[T].__setitem__()
list[T].append()
list[T].pop()
list[T].remove()
max()
min()
range()
round()
str.__bool__()
str.__init__()
str.__len__()
sum()
tuple[...].__getitem__()
indie
Main package of Indie language.
Algorithm
@algorithm()
algorithms
@band()
Color
color
Context
@fill()
Fill
format
@indicator()
IndieError
@level()
line_style
MainContext
MutSeries
MutSeriesF
Optional
param
@param_ref()
@plot()
Plot
plot_style
@sec_context()
SecContext
Series
SeriesF
source
SymbolInfo
tf()
TimeFrame
Algorithm
type
Base class for the classes that perform some processing of series data.
Color
type
Data type to represent color.
Context
type
Data type that represents an instrument with OHLCV series values and other related information.
bar_count
bar_index
calc_on()
close
high
hl2
hlc3
info
is_last_bar
is_last_history_bar
is_realtime
low
new_mut_series_f()
ohlc4
open
time
time_frame
volume
MainContext
SecContext
SymbolInfo
Series[T]
Fill
type
Class that represents a fill object.
IndieError
type
Data type for Indie errors.
MainContext
type
Base class for the class that represents main context.
bar_count
bar_index
calc_on()
close
high
hl2
hlc3
info
is_last_bar
is_last_history_bar
is_realtime
low
new_mut_series_f()
ohlc4
open
time
time_frame
volume
MutSeriesF
type
Data type that represents read-write series of float values like prices of some instrument. Type MutSeriesF
is nothing but an alias for type MutSeries[float]
.
__getitem__()
__len__()
__setitem__()
calc()
get()
new()
request_size()
Series[T]
SeriesF
MutSeries[T]
Context
MutSeries[T]
type
Generic data type that represents read-write series of values of type T
. Type T
could be float, int, str, or almost any other type.
__getitem__()
__len__()
__setitem__()
calc()
get()
new()
request_size()
Series[T]
SeriesF
MutSeriesF
Context
Optional[T]
type
Builtin Indie type (similar to Python's typing.Optional
).
Plot
type
Class that represents a plot object.
SecContext
type
Base class for the classes that represent additional contexts besides the main one.
bar_count
bar_index
calc_on()
close
high
hl2
hlc3
info
is_last_bar
is_last_history_bar
is_realtime
low
new_mut_series_f()
ohlc4
open
time
time_frame
volume
SeriesF
type
Data type that represents read only series of float values like prices of some instrument. Type SeriesF
is nothing but an alias for type Series[float]
.
__getitem__()
__len__()
get()
request_size()
Series[T]
MutSeries[T]
MutSeriesF
Context
Series[T]
type
Generic data type that represents read only series of values of type T
. Type T
could be float, int, str, or almost any other type.
__getitem__()
__len__()
get()
request_size()
SeriesF
MutSeries[T]
MutSeriesF
Context
SymbolInfo
type
Data type to represent information about the context's instrument.
exchange_aliases
exchange_code
marketdata_timezone
price_precision
tick_size
ticker
TimeFrame
type
Data type that represents time frame.
Use tf()
to create TimeFrame instances.
format
type
Enum-like class with constants that determine how to format the indicator value on the price scale.
line_style
type
Enum-like class with constants of line styles.
param
type
Class with decorators of indicator input parameters of various types.
@bool()
@float()
@int()
@source()
@string()
@time_frame()
plot_style
type
Enum-like class with constants of plot styles.
source
type
Enum-like class with constants for various price sources (it is used in @indie.param.source
).
CLOSE
HIGH
HL2
HLC3
LOW
OHLC4
OPEN
VOLUME
@algorithm()
decorator
Decorates a function, making it a series processor algorithm. Such algorithms are specifically designed to process series of data, like close prices of an instrument of a candle chart. One way of using such an algorithm is to call new
static method, read more here.
@algorithm() -> NoneType
Most of the functions in the indie.algorithms
package are decorated with @indie.algorithm
decorator. Read more about it in Series processors chapter.
@band()
decorator
Use this decorator to add a band (two horizontal lines usually with a semi-transparent fill in between them) to indicator.
@band(
value1: float,
value2: float,
title: indie.Optional[str] = None,
fill_color: indie.Color = indie.color.GREEN(0.05),
line_color: indie.Color = indie.color.GRAY(0.5),
line_style: int = indie.line_style.DASHED,
line_width: int = 1
) -> NoneType
PARAMETERS
value1
— Value of the first horizontal line of a band on a vertical scale of an indicator.
value2
— Value of the second horizontal line of a band on a vertical scale of an indicator.
title
— Human readable title which is visible in the indicator's Settings panel.
fill_color
— Color of the background.
line_color
— Color of the line.
line_style
— Style of the line. It is represented as enum value of type line_style
.
line_width
— Width of the line.
EXAMPLE
@indicator('Band example')
@band(145, 155, line_color=color.RED, line_width=4)
def Main(self):
return self.close[0]
@fill()
decorator
Declares attributes of a fill between some two plots of an indicator. Could be applied only to the Main
entry point of the indicator. Example of an indicator with a single colored fill is Bollinger Bands (BB), of a multicolored fill — Ichimoku Cloud. When applied, it must match with the result of the Main
indicator entry point.
@fill(
id1: str,
id2: str,
id: indie.Optional[str] = None,
title: indie.Optional[str] = None,
color: indie.Optional[indie.Color] = None
) -> NoneType
PARAMETERS
id1
— Identifier of the first plot to which the fill is applied.
id2
— Identifier of the second plot to which the fill is applied.
id
— Identifier of the fill (auto generated).
title
— Human readable title which is visible in the indicator's Settings panel.
color
— Color of the fill on a chart. This color can be overwritten if the fill is a multicolored one.
EXAMPLE
@plot('one')
@plot('two')
@fill('one', 'two', color=color.GREEN)
def Main(self):
return self.high[0], self.low[0], Fill()
More info about fills (for example about multicolored ones) could be found in Fills, levels and bands chapter.
@indicator()
decorator
Decorator that should be applied to the Main
entry point of any indicator.
@indicator(
abbrev_title: str,
overlay_main_pane: bool = False,
format: int = indie.format.INHERITED,
precision: indie.Optional[int] = None
) -> NoneType
PARAMETERS
abbrev_title
— Abbreviated title of the indicator.
overlay_main_pane
— Whether or not to overlay the indicator over the main pane of the chart. The main pane of a chart is the one with the main instrument on it.
format
— Formatting style of indicator output values represented as enum value of type format
.
precision
— Number of digits after floating point for indicator output values.
@level()
decorator
Decorator that is used to create a level (horizontal line) in an indicator.
@level(
value: float,
title: indie.Optional[str] = None,
line_color: indie.Color = indie.color.GRAY(0.5),
line_style: int = indie.line_style.DASHED,
line_width: int = 1
) -> NoneType
PARAMETERS
value
— Value of the level on a vertical scale of an indicator.
title
— Human readable title which is visible in the indicator's Settings panel.
line_color
— Color of the line.
line_style
— Style of the line. It is represented as enum value of type line_style
.
line_width
— Width of the line.
EXAMPLE
@indicator('Level example')
@level(150, line_color=color.RED, line_width=4)
def Main(self):
return self.close[0]
@param.bool()
decorator
Declares a bool input parameter of indicator. Values of input parameters can be changed in indicator's Settings panel. Input parameters are used in combination with corresponding parameter declaration in Main
entry point.
@bool(
id: str,
default: bool,
title: indie.Optional[str] = None
) -> NoneType
PARAMETERS
id
— Name of Main
function or class parameter bound to the input parameter.
default
— Default value for the parameter in settings pane.
title
— Human readable title which is visible in the indicator's Settings panel.
EXAMPLE
@param.bool('is_something_enabled', default=False)
def Main(self, is_something_enabled):
# Use is_something_enabled variable...
@param.float()
decorator
Declares a float input parameter of indicator. Values of input parameters can be changed in indicator's Settings panel. Input parameters are used in combination with corresponding parameter declaration in Main
entry point.
@float(
id: str,
default: float,
min: float = -1000000.0,
max: float = 1000000.0,
step: float = 0.1,
title: indie.Optional[str] = None
) -> NoneType
PARAMETERS
id
— Name of Main
function or class parameter bound to the input parameter.
default
— Default value for the parameter in settings pane.
min
— Minimum value of the parameter.
max
— Maximum value of the parameter.
step
— Step between values of the parameter.
title
— Human readable title which is visible in the indicator's Settings panel.
EXAMPLE
@param.float('speed_of_light', default=299_792.458)
def Main(self, speed_of_light):
# Use speed_of_light variable...
@param.int()
decorator
Declares an integer input parameter of indicator. Values of input parameters can be changed in indicator's Settings panel. Input parameters are used in combination with corresponding parameter declaration in Main
entry point.
@int(
id: str,
default: int,
min: int = -1000000,
max: int = 1000000,
step: int = 1,
title: indie.Optional[str] = None
) -> NoneType
PARAMETERS
id
— Name of Main
function or class parameter bound to the input parameter.
default
— Default value for the parameter in settings pane.
min
— Minimum value of the parameter.
max
— Maximum value of the parameter.
step
— Step between values of the parameter.
title
— Human readable title which is visible in the indicator's Settings panel.
EXAMPLE
@param.int('meaning_of_life', default=42)
def Main(self, meaning_of_life):
# Use meaning_of_life variable...
@param.source()
decorator
Declares a source input parameter of indicator. Values of input parameters can be changed in indicator's Settings panel. Input parameters are used in combination with corresponding parameter declaration in Main
entry point.
@source(
id: str,
default: int = source.CLOSE,
options: indie.Optional[list[int]] = None,
title: indie.Optional[str] = None
) -> NoneType
PARAMETERS
id
— Name of Main
function or class parameter bound to the input parameter.
default
— Default value for the parameter in settings pane.
options
— List of the possible values of the parameter.
title
— Human readable title which is visible in the indicator's Settings panel.
EXAMPLE
@param.source('src', default=source.CLOSE, options=[source.CLOSE, source.HL2, source.HLC3, source.OHLC4])
def Main(self, src):
# Use src variable...
Even if options
parameter is not used then in Settings panel nevertheless there will be a combobox widget with all possible values from the source
enum.
@param.string()
decorator
Declares a string input parameter of indicator. Values of input parameters can be changed in indicator's Settings panel. Input parameters are used in combination with corresponding parameter declaration in Main
entry point.
@string(
id: str,
default: str,
options: indie.Optional[list[str]] = None,
title: indie.Optional[str] = None
) -> NoneType
PARAMETERS
id
— Name of Main
function or class parameter bound to the input parameter.
default
— Default value for the parameter in settings pane.
options
— List of the possible values of the parameter.
title
— Human readable title which is visible in the indicator's Settings panel.
EXAMPLE
@param.string('name', default='Bart', options=['Homer', 'Marge', 'Bart', 'Lisa', 'Maggie'])
def Main(self, name):
# Use name variable...
If options
parameter is used then in Settings panel there will be a combobox widget for changing value of this input.
@param.time_frame()
decorator
Declares a time frame input parameter of indicator. Values of input parameters can be changed in indicator's Settings panel. Input parameters are used in combination with corresponding parameter declaration in Main
entry point.
@time_frame(
id: str,
default: str,
options: indie.Optional[list[str]] = None,
title: indie.Optional[str] = None
) -> NoneType
PARAMETERS
id
— Name of Main
function or class parameter bound to the input parameter.
default
— Default value for the parameter in settings pane.
options
— List of the possible values of the parameter.
title
— Human readable title which is visible in the indicator's Settings panel.
EXAMPLE
@param.time_frame('time_frame', default='30m', options=['1m', '30m', '1h', '4h', '1D', '1W', '1M', '1Y'])
def Main(self, time_frame):
# Use time_frame variable...
The type of time_frame
in the example variable will be TimeFrame
. But please note, that for the convenience, default value has str
type. String representation of TimeFrame
has a form of <number>[m|h|D|W|M|Y]
where suffixes mean: m
- minutes, h
- hours, D
- days, W
- weeks, M
- months, Y
- years.
If options
parameter is used then in Settings panel there will be a combobox widget for changing value of this input.
@indicator()
param
TimeFrame
tf()
@param_ref()
decorator
Declares an input parameter for @sec_context
function that is linked to the input parameter of Main
by id
.
@param_ref(id: str) -> NoneType
PARAMETERS
id
— Name of Main
function or class parameter bound to the input parameter.EXAMPLE
@sec_context
@param_ref('referenced_param')
def SecMain(self, referenced_param) -> float:
# Use referenced_param variable...
@indicator('Referenced param example')
@param.int('referenced_param', default=50)
class Main(MainContext):
def __init__(self):
self._calc_on_result = self.calc_on(time_frame=tf('1D'), sec_context=SecMain)
def calc(self):
return self._calc_on_result[0]
@plot()
decorator
Declares attributes of a plot of an indicator. Could be applied only to the Main
entry point of the indicator. It is optional, so may be omitted in some simple use cases and plot will be rendered using defaults. When applied, it must match with the result of the Main
indicator entry point.
@plot(
id: indie.Optional[str] = None,
title: indie.Optional[str] = None,
color: indie.Optional[indie.Color] = None,
style: int = indie.plot_style.LINE,
line_style: indie.Optional[int] = None,
line_width: indie.Optional[int] = None,
continuous: indie.Optional[bool] = None,
base_value: indie.Optional[float] = None,
rel_width: indie.Optional[float] = None
) -> NoneType
PARAMETERS
id
— A unique identifier of plot which is used in cases when a @fill()
should be applied between some of the two plots of an indicator.
title
— Human readable title which is visible in the indicator's Settings panel.
color
— Color of the plot on a chart. This color could be overwritten if the plot is a multicolored one. Example of an indicator with a multicolored plot is Awesome Oscillator (AO).
style
— Determines how the plot data is rendered. It is represented as enum value of type plot_style
.
line_style
— Style of the line. Could be only used in combination with plot_style.LINE
. It is represented as enum value of type line_style
.
line_width
— Width of the line. Could be only used in combination with plot_style.LINE
, plot_style.STEPS
or plot_style.HISTOGRAM
.
continuous
— Whether the plot should be continuous when the indicator has NaN
values. Could be only used in combination with plot_style.LINE
.
base_value
— Base value. Could be only used in combination with plot_style.HISTOGRAM
or plot_style.COLUMNS
.
rel_width
— Relative width. Could be only used in combination with plot_style.COLUMNS
.
EXAMPLE
@plot()
@plot()
@plot(style=plot_style.HISTOGRAM)
# @plot() - for the fourth plot could be omitted
def Main(self):
return self.open[0], self.high[0], self.low[0], self.close[0]
@sec_context()
decorator
Decorates a function, making it a secondary Main
entry point for additional instrument of an indicator. Additional instruments are requested with the help of Context.calc_on
function and this decorator.
@sec_context() -> NoneType
# indie:lang_version = 4
from indie import indicator, sec_context, param
@sec_context
def Main2(self):
return self.high[0], self.low[0]
@indicator('Minimal calc_on example', overlay_main_pane=True)
@param.time_frame('sec_time_frame', default='1D')
class Main(MainContext):
def __init__(self, sec_time_frame):
self._sec_high, self._sec_low = self.calc_on(time_frame=sec_time_frame, sec_context=Main2)
def calc(self):
return self._sec_high[0], self._sec_low[0]
More info on this topic you can find in Request additional instruments chapter.
@indicator()
Context
Context.calc_on()
Algorithm.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Color.__call__()
method
Creates a new Color instance with the given transparency applied to the existing color.
__call__(alpha: float) -> indie.Color
PARAMETERS
alpha
— Alpha channel (component) of color which ranges from 0.0
(fully transparent) to 1.0
(fully opaque).EXAMPLE
half_transparent_red = color.RED(0.5) # This implicitly calls `color.RED.__call__(0.5)`
Method __call__
should never be called directly, instead color_obj(value)
syntax should be used.
Context.calc_on()
method
Requests additional instrument (creates a secondary context object for it) for indicator and returns one or more SeriesF
objects which match with the arity of values that sec_context
function returns. All the returned series values are merged into the timescale of current context's instrument.
calc_on(
sec_context: typing.Type[indie.SecContext],
exchange: indie.Optional[str] = None,
ticker: indie.Optional[str] = None,
time_frame: indie.Optional[indie.TimeFrame] = None,
lookahead: bool = False
) -> indie.SeriesF | tuple[indie.SeriesF, ...]
PARAMETERS
sec_context
— Function decorated with @indie.sec_context
. This function has the same semantics as Indie Main
, but for additional instrument (not the main one).
exchange
— Alias for exchange of additional instrument. If omitted, then the exchange of the current context's instrument will be used.
ticker
— Ticker of an additional instrument. If omitted, then the ticker of the current context's instrument will be used.
time_frame
— Time frame of additional instrument. If omitted, then the time frame of current context's instrument will be used. At the moment it is allowed to request only time frames which are higher or equal to the time frame of current context's instrument.
lookahead
— If this flag is true, then when calculating history, the bars of the secondary context are merged with the bars of the current context based on their opening time. Such a data merge strategy may result in unintended use of data from future history.
REMARKS
At least one of optional arguments (exchange
, ticker
or time_frame
) must be provided. More info about this function as well as code examples you may find in Request additional instruments chapter.
Context.new_mut_series_f()
method
Creates a MutSeriesF
(an alias for MutSeries[float]
) object, which is a container for float
values in Indie code. The main feature of the MutSeriesF
container is its ability to store (or 'remember') the historical values of a variable. These values can be accessed later using the square brackets operator (via the __getitem__
method).
new_mut_series_f(
size: indie.Optional[int] = None,
default: indie.Optional[float] = None
) -> indie.MutSeries[float]
PARAMETERS
size
— Number of elements that MutSeriesF
object should store in memory. Default and possible minimum size is 2, which means that series of size = 2
stores in memory value at the time of the last candle and value at the time of previous candle. Size is automatically expanded during history calculation of an indicator. MutSeriesF
objects also have a method request_size(new_size: int)
which can be used to expand the size explicitly.
default
— Default value that will be used if an element at the specified index cannot be extracted.
SEE ALSO
Fill.__init__()
method
Class constructor (initializer for the data type).
__init__(
offset: int = 0,
color: indie.Optional[indie.Color] = None
) -> NoneType
PARAMETERS
offset
— Offset (in bars) of the fill during its rendering.
color
— Color to overwrite the default one (that was set in a @fill()
decorator).
SEE ALSO
IndieError.__init__()
method
Class constructor (initializer for the data type).
__init__(msg: str) -> NoneType
PARAMETERS
msg
— Error message.SEE ALSO
MutSeries[T].__setitem__()
method
Sets value of MutSeries[T]
object at the specified index.
__setitem__(int, T) -> NoneType
PARAMETERS
<unnamed param>
— Index to assign value at.
<unnamed param>
— New value.
EXAMPLE
ms = MutSeries[float].new(init=0)
ms[0] = 42 # This implicitly calls `ms.__setitem__(0, 42)`
MutSeriesF.set_last(value: float)
but we like the syntax of square brackets. Maybe this will be fixed in the future versions of Indie, hard to say for sure. 2) Method __setitem__
should never be called directly, instead syntax series_obj[index] = value
should be used.
MutSeries[T].calc()
method
Recalculates a MutSeries[T]
object. In most cases, you can simply use the s[i] = ...
syntax instead, but this method allows you to pass an initialization value to the series.
calc(
reset: indie.Optional[T] = None,
init: indie.Optional[T] = None,
size: indie.Optional[int] = None
) -> indie.MutSeries[T]
PARAMETERS
reset
— Value that is written into the most recent element of the MutSeriesF
every time MutSeriesF.new
function is executed.
init
— Value that is written into the most recent element of the MutSeriesF
object only once after the MutSeriesF
object was created.
size
— Number of elements that MutSeriesF
object should store in memory. Default and possible minimum size is 2, which means that series of size = 2
stores in memory value at the time of the last candle and value at the time of previous candle. Size is automatically expanded during history calculation of an indicator. MutSeriesF
objects also have a method request_size(new_size: int)
which can be used to expand the size explicitly.
SEE ALSO
Context.new_mut_series_f()
MutSeries[T].new()
MutSeries[T]
MutSeries[T].new()
static method
Creates a MutSeries[T]
object, which is a container for T
values in Indie code. The main feature of the MutSeries[T]
container is its ability to store (or 'remember') the historical values of a variable. These values can be accessed later using the square brackets operator (via the __getitem__
method).
new(
reset: indie.Optional[T] = None,
init: indie.Optional[T] = None,
size: indie.Optional[int] = None
) -> indie.MutSeries[T]
PARAMETERS
reset
— Value that is written into the most recent element of the MutSeriesF
every time MutSeriesF.new
function is executed.
init
— Value that is written into the most recent element of the MutSeriesF
object only once after the MutSeriesF
object was created.
size
— Number of elements that MutSeriesF
object should store in memory. Default and possible minimum size is 2, which means that series of size = 2
stores in memory value at the time of the last candle and value at the time of previous candle. Size is automatically expanded during history calculation of an indicator. MutSeriesF
objects also have a method request_size(new_size: int)
which can be used to expand the size explicitly.
SEE ALSO
Context.new_mut_series_f()
MutSeries[T]
Optional[T].__bool__()
method
Casts Optional
object to bool.
__bool__() -> bool
Optional[T].value()
method
Returns value of indie.Optional[T]
object. Raises a runtime error if the optional object is None
.
value() -> T
Optional[T].value_or()
method
Returns value of indie.Optional[T]
object or given default
if the optional object is None
.
value_or(default: T) -> T
PARAMETERS
default
— Default value that will be used if there is no value.SEE ALSO
Plot.__init__()
method
Class constructor (initializer for the data type).
__init__(
value: float,
offset: int = 0,
color: indie.Optional[indie.Color] = None
) -> NoneType
PARAMETERS
value
— Value that will be used as the current value of the plot.
offset
— Offset (in bars) of the plot during its rendering.
color
— Color to overwrite the default one (that was set in a @plot()
decorator).
SEE ALSO
Series[T].__getitem__()
method
Returns value of Series[T]
object at the specified index. If the value is missing, then the default value of type T
is returned (e.g. math.nan
if T
is float).
__getitem__(int) -> T
PARAMETERS
<unnamed param>
— Index to extract value at.EXAMPLE
@indicator('Example')
def Main(self):
return self.close[0] # This implicitly calls `self.close.__getitem__(0)`
Method __getitem__
should never be called directly. Instead syntax series_obj[index]
should be used.
Series[T].__len__()
method
Returns length (number of elements) of a Series[T]
object.
__len__() -> int
l = len(self.close) # this implicitly calls `self.close.__len__()`
Method __len__
should never be called directly. Instead syntax len(series_obj)
should be used.
Series[T].get()
method
Returns value of Series[T]
object at the specified index or given default
if the value is missing.
get(offset: int, default: T) -> T
PARAMETERS
offset
— Index to extract value at.
default
— Default value that will be used if an element at the specified index cannot be extracted.
SEE ALSO
Series[T].request_size()
method
Expands the capacity of Series[T]
object (number of elements that Series[T]
object should store in memory).
request_size(size: int) -> NoneType
PARAMETERS
size
— Number of elements that SeriesF
object should store in memory. Default and possible minimum size is 2, which means that series of size = 2
stores in memory value at the time of the last candle and value at the time of previous candle. Size is automatically expanded during history calculation of an indicator.SEE ALSO
TimeFrame.to_minutes()
method
Converts TimeFrame
object to corresponding number of minutes. Month is always considered to be of 30 days long, and year is always of 365 days long.
to_minutes() -> int
tf()
function
Converts string representation of time frame to TimeFrame
type. String representation of TimeFrame
has a form of <number>[m|h|D|W|M|Y]
where suffixes mean: m
- minutes, h
- hours, D
- days, W
- weeks, M
- months, Y
- years. For example tf('15m')
creates a TimeFrame
object which corresponds to 15 minute time frame.
tf(s: str = None) -> indie.TimeFrame
PARAMETERS
s
— String representation of time frame.SEE ALSO
Algorithm.ctx
field
Represents context of an instrument which is currently bound to this algorithm instance. An indicator has at least one instrument — the main instrument of a chart where the indicator was added to. Besides the main instrument an indicator may have several additional instruments, which is done with the help of Context.calc_on
function.
Context.bar_count
field
Current total number of bars in this context's instrument which the indicator has received. It is always true that self.bar_count
is equal to self.bar_index + 1
.
Context.bar_index
field
Index of a last (current) bar in this context's instrument which the indicator has received. The very first bar has index equal to 0
and this is the oldest bar.
Context.close
field
Series of 'close' prices of the context's instrument.
Context.high
field
Series of 'high' prices of the context's instrument.
Context.hl2
field
Series of '(high + low) / 2' values of the context's instrument.
Context.hlc3
field
Series of '(high + low + close) / 3' values of the context's instrument.
Context.info
field
Information about the context's instrument.
Context.is_last_bar
field
Flag that is True
if the current bar is the last bar in the history or it is a realtime bar.
Context.is_last_history_bar
field
Flag that is True
if the current bar is the last bar of the historical part of prices data.
Context.is_realtime
field
Flag that is True
if the last (current) bar is a realtime bar.
Context.low
field
Series of 'low' prices of the context's instrument.
Context.ohlc4
field
Series of '(open + high + low + close) / 4' values of the context's instrument.
Context.open
field
Series of 'open' prices of the context's instrument.
Context.time
field
Series of timestamps (as unix time UTC seconds) of the context's instrument. Every timestamp corresponds to start time of some bar on a chart.
Context.time_frame
field
Time frame of the context's instrument.
Context.volume
field
Series of 'volume' values of the context's instrument.
SymbolInfo.exchange_aliases
field
Commonly recognized (but not exactly standardized) alias for an exchange. For example, an alias for the New York Stock Exchange, Inc. is 'NYSE'
. In most cases exchange alias matches with the exchange acronym (see ISO10383).
SymbolInfo.exchange_code
field
Exchange code of the context's instrument. For stocks it is a MIC. For crypto instruments it is just some identifier, not commonly recognized as MIC but unique within TakeProfit. For example, exchange_code
for the New York Stock Exchange, Inc. is 'XNYS'
.
SymbolInfo.marketdata_timezone
field
Name of the exchange timezone of the context's instrument. For example, 'America/New_York'
.
SymbolInfo.price_precision
field
Price precision of the context's instrument. For example, price precision of 100
means that prices have two digits after the floating point.
SymbolInfo.tick_size
field
Absolute value of a minimal movement of a price of the context's instrument in corresponding currency.
SymbolInfo.ticker
field
Ticker of the context's instrument.
format.INHERITED
static field
Indicator output values are formatted same as values of the main chart instrument.
format.PRICE
static field
Indicator output values are formatted using fixed number of digits after the floating point. The number of digits is set with additional parameter precision
of @indicator()
. The precision
param has effect only in combination with the format.PRICE
format.
format.VOLUME
static field
Indicator output values are formatted according to the rules of formatting large numbers, such as volumes of trades. For example 100500.0
will be formatted as 100.5K
.
line_style.DASHED
static field
Built-in line style constant that determines how the line is rendered.
line_style.DOTTED
static field
Built-in line style constant that determines how the line is rendered.
line_style.SOLID
static field
Built-in line style constant that determines how the line is rendered.
plot_style.COLUMNS
static field
Built-in plot style constant that determines how the plot data is rendered.
plot_style.HISTOGRAM
static field
Built-in plot style constant that determines how the plot data is rendered.
plot_style.LINE
static field
Built-in plot style constant that determines how the plot data is rendered.
plot_style.STEPS
static field
Built-in plot style constant that determines how the plot data is rendered.
source.CLOSE
static field
Built-in source kind constant which corresponds to Context
's series field and is used to initialize source input parameter.
source.HIGH
static field
Built-in source kind constant which corresponds to Context
's series field and is used to initialize source input parameter.
source.HL2
static field
Built-in source kind constant which corresponds to Context
's series field and is used to initialize source input parameter.
source.HLC3
static field
Built-in source kind constant which corresponds to Context
's series field and is used to initialize source input parameter.
source.LOW
static field
Built-in source kind constant which corresponds to Context
's series field and is used to initialize source input parameter.
source.OHLC4
static field
Built-in source kind constant which corresponds to Context
's series field and is used to initialize source input parameter.
source.OPEN
static field
Built-in source kind constant which corresponds to Context
's series field and is used to initialize source input parameter.
source.VOLUME
static field
Built-in source kind constant which corresponds to Context
's series field and is used to initialize source input parameter.
indie.algorithms
Algorithms package of Indie language.
Adx
Atr
Bb
Cci
Change
CumSum
Dev
Donchian
Ema
FixNan
Highest
Lowest
Ma
Median
Mfv
NanToZero
NetVolume
PercentRank
Rma
Roc
Rsi
SinceHighest
SinceLowest
Sma
StdDev
Stoch
Sum
Supertrend
Tr
Tsi
Vwap
Vwma
Wma
Adx
type
Average directional index algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import nan, isclose
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Change, Rma, Tr, FixNan
@algorithm
def Adx(self, adx_len: int, di_len: int) -> tuple[SeriesF, SeriesF, SeriesF]:
'''Average Directional Index'''
up = Change.new(self.ctx.high)[0]
down = -Change.new(self.ctx.low)[0]
plus_dm = MutSeriesF.new(0 if up <= down or up <= 0 else up)
minus_dm = MutSeriesF.new(0 if down <= up or down <= 0 else down)
truerange = Rma.new(Tr.new(), di_len)
plus = MutSeriesF.new(init=nan)
minus = MutSeriesF.new(init=nan)
if not isclose(truerange[0], 0):
plus[0] = 100 * Rma.new(plus_dm, di_len)[0] / truerange[0]
minus[0] = 100 * Rma.new(minus_dm, di_len)[0] / truerange[0]
plus[0] = FixNan.new(plus)[0]
minus[0] = FixNan.new(minus)[0]
sum = plus[0] + minus[0]
res = 100 * Rma.new(MutSeriesF.new(abs(plus[0] - minus[0]) / (sum if sum != 0 else 1)), adx_len)[0]
return minus, MutSeriesF.new(res), plus
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Adx
@indicator('Example')
def Main(self):
minus_di, adx, plus_di = Adx.new(adx_len=9, di_len=12)
return minus_di[0], adx[0], plus_di[0]
Atr
type
Average true range algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF
from indie.algorithms import Tr, Ma
@algorithm
def Atr(self, length: int, ma_algorithm: str = 'RMA') -> SeriesF:
'''Average True Range'''
return Ma.new(Tr.new(True), length, ma_algorithm)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Atr
@indicator('Example')
def Main(self):
atr = Atr.new(length=12, ma_algorithm='SMA')
return atr[0]
Bb
type
Bollinger bands algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Sma, StdDev
@algorithm
def Bb(self, src: SeriesF, length: int, mult: float) -> tuple[SeriesF, SeriesF, SeriesF]:
'''Bollinger Bands'''
middle = Sma.new(src, length)[0]
dev = mult * StdDev.new(src, length)[0]
lower = middle - dev
upper = middle + dev
return MutSeriesF.new(lower), MutSeriesF.new(middle), MutSeriesF.new(upper)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Bb
@indicator('Example', overlay_main_pane=True)
def Main(self):
lower, middle, upper = Bb.new(self.close, length=20, mult=2.0)
return lower[0], middle[0], upper[0]
Cci
type
Commodity channel index algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import nan, isclose
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Sma, Dev
@algorithm
def Cci(self, src: SeriesF, length: int) -> SeriesF:
'''Commodity Channel Index'''
ma = Sma.new(src, length)
dv = Dev.new(src, length)[0]
res = nan
if not isclose(dv, 0):
res = (src[0] - ma[0]) / (0.015 * dv)
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Cci
@indicator('Example')
def Main(self):
cci = Cci.new(self.close, length=20)
return cci[0]
Change
type
Algorithm to calculate change of a series of values. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def Change(self, src: SeriesF, length: int = 1) -> SeriesF:
return MutSeriesF.new(src[0] - src[length])
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Change
@indicator('Example')
def Main(self):
ch = Change.new(self.close)
return ch[0]
CumSum
type
Cumulative sum algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def CumSum(self, src: SeriesF) -> SeriesF:
res = MutSeriesF.new(init=0)
res[0] += src[0]
return res
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import CumSum
@indicator('Example')
def Main(self):
cs = CumSum.new(self.close)
return cs[0]
Dev
type
Mean absolute deviation algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Sma
@algorithm
def Dev(self, src: SeriesF, length: int) -> SeriesF:
'''Mean Absolute Deviation'''
mean = Sma.new(src, length)[0]
sum = 0.0
for i in range(length):
sum += abs(src[i] - mean)
return MutSeriesF.new(sum / length)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Dev
@indicator('Example')
def Main(self):
dev = Dev.new(self.close, length=12)
return dev[0]
Donchian
type
Donchian channels algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, MutSeriesF, SeriesF
from indie.algorithms import Lowest, Highest
@algorithm
def Donchian(self, length: int) -> SeriesF:
lowest = Lowest.new(self.ctx.low, length)[0]
highest = Highest.new(self.ctx.high, length)[0]
return MutSeriesF.new((lowest + highest) / 2)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Donchian
@indicator('DC', overlay_main_pane=True)
def Main(self):
d = Donchian.new(length=20)
return d[0]
Ema
type
Exponential moving average algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import isnan, nan
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Sma
@algorithm
def Ema(self, src: SeriesF, length: int) -> SeriesF:
'''Exponential Moving Average'''
alpha = 2 / (length + 1)
s = MutSeriesF.new(init=0)
res_sma = Sma.new(src, length)[0]
result = 0.0
if isnan(src[0]):
s[0] = nan
result = res_sma
elif isnan(s[1]):
s[0] = res_sma
result = s[0]
else:
s[0] = alpha * src[0] + (1 - alpha) * s[1]
result = s[0]
return MutSeriesF.new(result)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Ema
@indicator('Example', overlay_main_pane=True)
def Main(self):
ema = Ema.new(self.close, length=9)
return ema[0]
FixNan
type
Algorithm that replaces all math.nan
values with the most recent corresponding non-nan values in a series. Read here about how to use it.
# indie:lang_version = 4
from math import isnan
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def FixNan(self, src: SeriesF) -> SeriesF:
res = MutSeriesF.new(init=src[0])
if not isnan(src[0]):
res[0] = src[0]
return res
# indie:lang_version = 4
import math
from indie import indicator, MutSeriesF
from indie.algorithms import FixNan
@indicator('Example', overlay_main_pane=True)
def Main(self):
# Variable `s` is just an example of a series with `nan` values:
s = MutSeriesF.new(math.nan)
if self.close[0] > self.open[0]:
s[0] = self.close[0]
# `FixNan` replaces every `nan` value in `s` with the closest non-`nan` value on the left of it:
s2 = FixNan.new(s)
return s2[0]
Highest
type
Algorithm that returns the maximum value over a given period. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def Highest(self, src: SeriesF, length: int) -> SeriesF:
src.request_size(length)
result = src[0]
for i in range(1, length):
result = max(src[i], result)
return MutSeriesF.new(result)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Highest
@indicator('My Indie 1', overlay_main_pane=True)
def Main(self):
h = Highest.new(self.high, length=12)
return h[0]
Lowest
type
Algorithm that returns the minimum value over a given period. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def Lowest(self, src: SeriesF, length: int) -> SeriesF:
src.request_size(length)
result = src[0]
for i in range(1, length):
result = min(src[i], result)
return MutSeriesF.new(result)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Lowest
@indicator('My Indie 1', overlay_main_pane=True)
def Main(self):
l = Lowest.new(self.low, length=12)
return l[0]
Ma
type
Moving average algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF, Optional, IndieError
from indie.algorithms import Ema, Sma, Rma, Vwma, Wma
@algorithm
def Ma(self, src: SeriesF, length: int, algorithm: str) -> SeriesF:
'''Moving Average'''
result: Optional[SeriesF]
if algorithm == 'EMA':
result = Ema.new(src, length)
elif algorithm == 'SMA':
result = Sma.new(src, length)
elif algorithm == 'SMMA (RMA)' or algorithm == 'RMA':
result = Rma.new(src, length)
elif algorithm == 'VWMA':
result = Vwma.new(src, length)
elif algorithm == 'WMA':
result = Wma.new(src, length)
else:
raise IndieError("moving average algorithm should be one of 'EMA', 'SMA', "
"'SMMA (RMA)', 'RMA', 'VWMA' or 'WMA' but it is " + algorithm)
return result.value()
# indie:lang_version = 4
from indie.algorithms import Ma
@indicator('Example', overlay_main_pane=True)
def Main(self):
ma = Ma.new(self.close, length=12, algorithm='SMA')
return ma[0]
Median
type
Moving median algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
from statistics import median as stats_median
# TODO: Use quickselect median find algorithm, see more https://rcoh.me/posts/linear-time-median-finding/
@algorithm
def Median(self, src: SeriesF, length: int) -> SeriesF:
prices: list[float] = [] # TODO: Create list of size=length only once and clear+refill it
for i in range(length):
prices.append(src[i])
res = stats_median(prices) # type: ignore
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Median
@indicator('Example', overlay_main_pane=True)
def Main(self):
m = Median.new(self.close, length=10)
return m[0]
Mfv
type
Money flow volume algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import isclose
from indie import algorithm, MutSeriesF, SeriesF
@algorithm
def Mfv(self) -> SeriesF:
'''Money Flow Volume'''
h = self.ctx.high[0]
l = self.ctx.low[0]
c = self.ctx.close[0]
v = self.ctx.volume[0]
res = 0.0
if not isclose(h - l, 0):
res = ((c - l) - (h - c)) / (h - l) * v
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Mfv
@indicator('Example')
def Main(self):
mfv = Mfv.new()
return mfv[0]
NanToZero
type
Algorithm that replaces all math.nan
values with zeros in a series. Read here about how to use it.
# indie:lang_version = 4
from math import isnan
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def NanToZero(self, src: SeriesF) -> SeriesF:
res = 0 if isnan(src[0]) else src[0]
return MutSeriesF.new(res)
# indie:lang_version = 4
import math
from indie import indicator, MutSeriesF
from indie.algorithms import NanToZero
@indicator('Example')
def Main(self):
# Variable `s` is just an example of a series with `nan` values:
s = MutSeriesF.new(math.nan)
if self.close[0] > self.open[0]:
s[0] = 0 if math.isnan(s[1]) else s[1] + 1
# `NanToZero` replaces every `nan` value in `s` with zero
s2 = NanToZero.new(s)
return s2[0]
NetVolume
type
Net volume algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import nan
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Change
@algorithm
def NetVolume(self, src: SeriesF) -> SeriesF:
der = Change.new(src)[0]
nv = MutSeriesF.new(init=nan)
if der > 0:
nv[0] = self.ctx.volume[0]
elif der < 0:
nv[0] = -self.ctx.volume[0]
elif der == 0:
nv[0] = 0
return nv
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import NetVolume
@indicator('Example')
def Main(self):
nv = NetVolume.new(self.close)
return nv[0]
PercentRank
type
Percent rank algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def PercentRank(self, src: SeriesF, length: int) -> SeriesF:
num_leq = 0
for idx in range(1, length + 1):
if src[idx] <= src[0]:
num_leq += 1
return MutSeriesF.new(100.0 * num_leq / length)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import PercentRank
@indicator('Example')
def Main(self):
pr = PercentRank.new(self.close, length=12)
return pr[0]
Rma
type
RMA algorithm is a moving average algorithm that is used to calculate RSI. Read here about how to use it.
# indie:lang_version = 4
from math import isnan
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Sma
@algorithm
def Rma(self, src: SeriesF, length: int) -> SeriesF:
'''RSI Moving Average'''
result = MutSeriesF.new(init=0)
if isnan(result[1]):
result[0] = Sma.new(src, length)[0]
else:
result[0] = (src[0] + (length - 1) * result[1]) / length
return result
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Rma
@indicator('My Indie 1', overlay_main_pane=True)
def Main(self):
rma = Rma.new(self.close, length=12)
return rma[0]
Roc
type
Rate of change algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import nan, isclose
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Change
@algorithm
def Roc(self, src: SeriesF, length: int) -> SeriesF:
'''Rate Of Change'''
res = nan
if not isclose(src[length], 0):
res = 100 * Change.new(src, length)[0] / src[length]
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Roc
@indicator('Example')
def Main(self):
roc = Roc.new(self.close, length=9)
return roc[0]
Rsi
type
Relative strength index algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import isclose
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import NanToZero, Change, Rma
@algorithm
def Rsi(self, src: SeriesF, length: int) -> SeriesF:
'''Relative Strength Index'''
u = max(NanToZero.new(Change.new(src))[0], 0) # upward change
rma_u = Rma.new(MutSeriesF.new(u), length)
d = max(-NanToZero.new(Change.new(src))[0], 0) # downward change
rma_d = Rma.new(MutSeriesF.new(d), length)
res = 100.0
if not isclose(rma_d[0], 0):
rs = rma_u[0] / rma_d[0]
res = 100 - 100 / (1 + rs)
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Rsi
@indicator('Example')
def Main(self):
rsi = Rsi.new(self.close, length=12)
return rsi[0]
SinceHighest
type
Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, MutSeriesF, SeriesF
@algorithm
def SinceHighest(self, src: SeriesF, length: int) -> SeriesF:
offset = 0
for idx in range(length):
if src[idx] >= src[offset]:
offset = idx
return MutSeriesF.new(offset)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import SinceHighest
@indicator('Example')
def Main(self):
sh = SinceHighest.new(self.high, length=10)
return sh[0]
SinceLowest
type
Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, MutSeriesF, SeriesF
@algorithm
def SinceLowest(self, src: SeriesF, length: int) -> SeriesF:
offset = 0
for idx in range(length):
if src[idx] <= src[offset]:
offset = idx
return MutSeriesF.new(offset)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import SinceLowest
@indicator('Example')
def Main(self):
sl = SinceLowest.new(self.high, length=10)
return sl[0]
Sma
type
Simple moving average algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Sum
@algorithm
def Sma(self, src: SeriesF, length: int) -> SeriesF:
'''Simple Moving Average'''
s = Sum.new(src, length)
return MutSeriesF.new(s[0] / length)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Sma
@indicator('Example')
def Main(self):
sma = Sma.new(self.close, length=12)
return sma[0]
StdDev
type
Standard deviation algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import sqrt
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Sma
@algorithm
def StdDev(self, src: SeriesF, length: int) -> SeriesF:
avg = Sma.new(src, length)
sum_of_square_deviations = 0.0
for i in range(length):
dev = src[i] - avg[0]
sum_of_square_deviations += dev * dev
return MutSeriesF.new(sqrt(sum_of_square_deviations / length))
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import StdDev
@indicator('Example')
def Main(self):
sd = StdDev.new(self.close, length=12)
return sd[0]
Stoch
type
Stochastic algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import isclose
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Lowest, Highest
@algorithm
def Stoch(self, src: SeriesF, low: SeriesF, high: SeriesF, length: int) -> SeriesF:
lowest_low = Lowest.new(low, length)[0]
highest_high = Highest.new(high, length)[0]
res = 100.0
if not isclose(highest_high - lowest_low, 0):
res = 100 * (src[0] - lowest_low) / (highest_high - lowest_low)
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Stoch
@indicator('Example')
def Main(self):
s = Stoch.new(self.close, self.low, self.high, length=14)
return s[0]
Sum
type
Sliding sum algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import isnan, nan
from indie import algorithm, SeriesF, MutSeriesF
def nan_to_zero(val: float) -> float:
return 0 if isnan(val) else val
@algorithm
def Sum(self, src: SeriesF, length: int) -> SeriesF:
src.request_size(length + 1)
nan_count = MutSeriesF.new(init=0)
sum = MutSeriesF.new(init=0) # TODO: Use Var[float].new for sum variable maybe?
sum[0] += nan_to_zero(src[0])
result = 0.0
if isnan(src[0]):
nan_count[0] += 1
result = nan
else:
if len(src) - nan_count[0] > length:
sum[0] -= src[length]
if len(src) - nan_count[0] < length:
result = nan
else:
result = sum[0]
return MutSeriesF.new(result)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Sum
@indicator('Example')
def Main(self):
s = Sum.new(self.close, length=10)
return s[0]
Supertrend
type
Supertrend algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import isnan
from indie import algorithm, MutSeriesF, SeriesF
from indie.algorithms import Atr
def nan_to_val(maybe_nan: float, val: float) -> float:
return val if isnan(maybe_nan) else maybe_nan
@algorithm
def Supertrend(self, factor: float, atr_period: int, ma_algorithm: str) -> tuple[SeriesF, SeriesF]:
src = self.ctx.hl2
atr = Atr.new(atr_period, ma_algorithm)
upper_band = MutSeriesF.new(src[0] + factor * atr[0])
lower_band = MutSeriesF.new(src[0] - factor * atr[0])
prev_lower_band = nan_to_val(lower_band[1], 0)
prev_upper_band = nan_to_val(upper_band[1], 0)
lower_band[0] = lower_band[0] \
if lower_band[0] > prev_lower_band or self.ctx.close[1] < prev_lower_band \
else prev_lower_band
upper_band[0] = upper_band[0] \
if upper_band[0] < prev_upper_band or self.ctx.close[1] > prev_upper_band \
else prev_upper_band
direction: float
super_trend = MutSeriesF.new(init=0)
prev_super_trend = super_trend[1]
if isnan(atr[1]):
direction = 1.0
elif prev_super_trend == prev_upper_band:
direction = -1.0 if self.ctx.close[0] > upper_band[0] else 1.0
else:
direction = 1.0 if self.ctx.close[0] < lower_band[0] else -1.0
super_trend[0] = lower_band[0] if direction < 0 else upper_band[0]
return super_trend, MutSeriesF.new(direction)
# indie:lang_version = 4
from indie import indicator, color, Plot
from indie.algorithms import Supertrend
@indicator('Example', overlay_main_pane=True)
def Main(self):
st, dir = Supertrend.new(factor=3.0, atr_period=10, ma_algorithm='SMA')
c = color.RED if dir[0] > 0 else color.GREEN
return Plot(st[0], color=c)
Tr
type
True range algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import nan, isnan
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def Tr(self, handle_na: bool = False) -> SeriesF:
'''True Range'''
res = nan if handle_na else self.ctx.high[0] - self.ctx.low[0]
if not isnan(self.ctx.close[1]):
res = max(
self.ctx.high[0] - self.ctx.low[0],
abs(self.ctx.high[0] - self.ctx.close[1]),
abs(self.ctx.low[0] - self.ctx.close[1]),
)
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Tr
@indicator('Example')
def Main(self):
tr = Tr.new()
return tr[0]
Tsi
type
True strength index algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import nan, isclose
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Ema, Change
@algorithm
def DoubleSmooth(self, src: SeriesF, long_len: int, short_len: int) -> SeriesF:
return Ema.new(Ema.new(src, long_len), short_len)
@algorithm
def Tsi(self, src: SeriesF, long_len: int, short_len: int) -> SeriesF:
'''True Strength Index'''
pc = Change.new(src)
double_smoothed_pc = DoubleSmooth.new(pc, long_len, short_len)[0]
abs_pc = MutSeriesF.new(abs(pc[0]))
double_smoothed_abs_pc = DoubleSmooth.new(abs_pc, long_len, short_len)[0]
res = nan
if not isclose(double_smoothed_abs_pc, 0):
res = double_smoothed_pc / double_smoothed_abs_pc
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Tsi
@indicator('Example')
def Main(self):
tsi = Tsi.new(self.close, long_len=21, short_len=12)
return tsi[0]
Vwap
type
Volume weighted average price algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import sqrt
from indie import algorithm, SeriesF, MutSeriesF
from datetime import datetime
@algorithm
def Vwap(self, src: SeriesF, anchor: str, std_dev_mult: float) -> tuple[SeriesF, SeriesF, SeriesF]:
'''
Volume Weighted Average Price
anchor can be 'Day', 'Week', 'Month', 'Year'
'''
cum_weighted_price = MutSeriesF.new(init=0)
cum_volume = MutSeriesF.new(init=0)
vwap_values = MutSeriesF.new(init=0)
vwap_sum = MutSeriesF.new(init=0)
vwap_count = MutSeriesF.new(init=0)
vwap_avg = MutSeriesF.new(init=0)
vwap_dev_squares = MutSeriesF.new(init=0)
vwap_std_dev = MutSeriesF.new(init=0)
current_datetime = datetime.utcfromtimestamp(self.ctx.time[0])
prev_datetime = datetime.utcfromtimestamp(self.ctx.time.get(1, 0))
need_reset = False
if anchor == 'Day' and (current_datetime.day != prev_datetime.day or
(current_datetime-prev_datetime).days >= 1):
need_reset = True
elif anchor == 'Week' and ((current_datetime.weekday() == 0 and prev_datetime.weekday() != 0) or
(current_datetime-prev_datetime).days >= 7):
need_reset = True
elif anchor == 'Month' and (current_datetime.month != prev_datetime.month or
(current_datetime-prev_datetime).days >= 31):
need_reset = True
elif anchor == 'Year' and current_datetime.year != prev_datetime.year:
need_reset = True
if need_reset:
cum_weighted_price[0] = 0.0
cum_volume[0] = 0.0
vwap_sum[0] = 0.0
vwap_count[0] = 0
vwap_dev_squares[0] = 0.0
cum_weighted_price[0] += src[0] * self.ctx.volume[0]
cum_volume[0] += self.ctx.volume[0]
vwap_values[0] = cum_weighted_price[0] / cum_volume[0]
vwap_sum[0] += vwap_values[0]
vwap_count[0] += 1
vwap_avg[0] = vwap_sum[0] / vwap_count[0]
vwap_dev_squares[0] += (vwap_values[0] - vwap_avg[0]) ** 2
vwap_std_dev[0] = sqrt(vwap_dev_squares[0] / vwap_count[0])
std_dev = std_dev_mult * vwap_std_dev[0]
lower = MutSeriesF.new(vwap_values[0] - std_dev)
upper = MutSeriesF.new(vwap_values[0] + std_dev)
return vwap_values, upper, lower
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Vwap
@indicator('Example', overlay_main_pane=True)
def Main(self):
main_line, upper, lower = Vwap.new(self.close, anchor='Day', std_dev_mult=1.0)
return main_line[0], upper[0], lower[0]
Vwma
type
Volume weighted moving average algorithm. Read here about how to use it.
# indie:lang_version = 4
from math import nan, isclose
from indie import algorithm, SeriesF, MutSeriesF
from indie.algorithms import Sma
@algorithm
def Vwma(self, src: SeriesF, length: int) -> SeriesF:
'''Volume Weighted Moving Average'''
src_vol = MutSeriesF.new(src[0] * self.ctx.volume[0])
sma_src_vol = Sma.new(src_vol, length)
sma_vol = Sma.new(self.ctx.volume, length)
res = nan
if not isclose(sma_vol[0], 0):
res = sma_src_vol[0] / sma_vol[0]
return MutSeriesF.new(res)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Vwma
@indicator('Example', overlay_main_pane=True)
def Main(self):
vwma = Vwma.new(self.close, length=12)
return vwma[0]
Wma
type
Weighted moving average algorithm. Read here about how to use it.
# indie:lang_version = 4
from indie import algorithm, SeriesF, MutSeriesF
@algorithm
def Wma(self, src: SeriesF, length: int) -> SeriesF:
'''Weighted Moving Average'''
norm = 0.0
s = 0.0
for i in range(length):
weight = length - i
norm += weight
s += src[i] * weight
return MutSeriesF.new(s / norm)
# indie:lang_version = 4
from indie import indicator
from indie.algorithms import Wma
@indicator('Example', overlay_main_pane=True)
def Main(self):
wma = Wma.new(self.close, length=12)
return wma[0]
Adx.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Adx.calc()
method
Returns series of Minus Directional Indicator, Average Directional Index and Plus Directional Indicator.
calc(
adx_len: int,
di_len: int
) -> tuple[indie.Series[float], indie.Series[float], indie.Series[float]]
PARAMETERS
adx_len
— Number of bars to calculate smoothing.
di_len
— Number of bars to calculate directional indicator.
SEE ALSO
Adx.new()
static method
Returns series of Minus Directional Indicator, Average Directional Index and Plus Directional Indicator.
new(
adx_len: int,
di_len: int
) -> tuple[indie.Series[float], indie.Series[float], indie.Series[float]]
PARAMETERS
adx_len
— Number of bars to calculate smoothing.
di_len
— Number of bars to calculate directional indicator.
SEE ALSO
Atr.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Atr.calc()
method
Returns series of Average True Range values calculated for the length
bars period using moving average specified by ma_algorithm
argument.
calc(length: int, ma_algorithm: str = "RMA") -> indie.Series[float]
PARAMETERS
length
— Number of bars in calculation taken into account.
ma_algorithm
— Moving average algorithm name, should be one of 'EMA'
, 'SMA'
, 'SMMA (RMA)'
, 'RMA'
, 'VWMA'
or 'WMA'
.
SEE ALSO
Atr.new()
static method
Returns series of Average True Range values calculated for the length
bars period using moving average specified by ma_algorithm
argument.
new(length: int, ma_algorithm: str = "RMA") -> indie.Series[float]
PARAMETERS
length
— Number of bars in calculation taken into account.
ma_algorithm
— Moving average algorithm name, should be one of 'EMA'
, 'SMA'
, 'SMMA (RMA)'
, 'RMA'
, 'VWMA'
or 'WMA'
.
SEE ALSO
Bb.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Bb.calc()
method
Returns middle, upper and lower series of Bollinger Bands calculated on src
series for the length
bars period.
calc(
src: indie.Series[float],
length: int,
mult: float
) -> tuple[indie.Series[float], indie.Series[float], indie.Series[float]]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
mult
— Multiplier for standard deviation.
SEE ALSO
Bb.new()
static method
Returns middle, upper and lower series of Bollinger Bands calculated on src
series for the length
bars period.
new(
src: indie.Series[float],
length: int,
mult: float
) -> tuple[indie.Series[float], indie.Series[float], indie.Series[float]]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
mult
— Multiplier for standard deviation.
SEE ALSO
Cci.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Cci.calc()
method
Returns series of Commodity Channel Index values calculated on src
series for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Cci.new()
static method
Returns series of Commodity Channel Index values calculated on src
series for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Change.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Change.calc()
method
Returns the difference between current src
value and its value length
bars ago.
calc(src: indie.Series[float], length: int = 1) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars ago to compare the current value.
SEE ALSO
Change.new()
static method
Returns the difference between current src
value and its value length
bars ago.
new(src: indie.Series[float], length: int = 1) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars ago to compare the current value.
SEE ALSO
CumSum.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
CumSum.calc()
method
Returns series of cumulative sum of src
values.
calc(src: indie.Series[float]) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.SEE ALSO
CumSum.new()
static method
Returns series of cumulative sum of src
values.
new(src: indie.Series[float]) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.SEE ALSO
Dev.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Dev.calc()
method
Returns series of Mean Absolute Deviation values calculated on src
series for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Dev.new()
static method
Returns series of Mean Absolute Deviation values calculated on src
series for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Donchian.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Donchian.calc()
method
Returns series of Middle Channel of Donchian Channels calculated for the length
bars period.
calc(length: int) -> indie.Series[float]
PARAMETERS
length
— Number of bars in calculation taken into account.SEE ALSO
Donchian.new()
static method
Returns series of Middle Channel of Donchian Channels calculated for the length
bars period.
new(length: int) -> indie.Series[float]
PARAMETERS
length
— Number of bars in calculation taken into account.SEE ALSO
Ema.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Ema.calc()
method
Returns series of Exponential Moving Average values calculated on src
series for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Ema.new()
static method
Returns series of Exponential Moving Average values calculated on src
series for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
FixNan.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
FixNan.calc()
method
Returns series created from src
by replacing math.nan
values with previous nearest non-nan
value.
calc(src: indie.Series[float]) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.SEE ALSO
FixNan.new()
static method
Returns series created from src
by replacing math.nan
values with previous nearest non-nan
value.
new(src: indie.Series[float]) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.SEE ALSO
Highest.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Highest.calc()
method
Returns maximum value of given src
series over a period of length
bars.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Highest.new()
static method
Returns maximum value of given src
series over a period of length
bars.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Lowest.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Lowest.calc()
method
Returns minimum value of given src
series over a period of length
bars.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Lowest.new()
static method
Returns minimum value of given src
series over a period of length
bars.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Ma.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Ma.calc()
method
Returns a moving average of src
specified by algorithm
argument.
calc(
src: indie.Series[float],
length: int,
algorithm: str
) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
algorithm
— Moving average algorithm name, should be one of 'EMA'
, 'SMA'
, 'SMMA (RMA)'
, 'RMA'
, 'VWMA'
or 'WMA'
.
SEE ALSO
Ma.new()
static method
Returns a moving average of src
specified by algorithm
argument.
new(
src: indie.Series[float],
length: int,
algorithm: str
) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
algorithm
— Moving average algorithm name, should be one of 'EMA'
, 'SMA'
, 'SMMA (RMA)'
, 'RMA'
, 'VWMA'
or 'WMA'
.
SEE ALSO
Median.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Median.calc()
method
Returns series of Moving Median values calculated from series of src
for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Median.new()
static method
Returns series of Moving Median values calculated from series of src
for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Mfv.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Mfv.calc()
method
Returns series of Money Flow Volume.
calc() -> indie.Series[float]
Mfv.new()
static method
Returns series of Money Flow Volume.
new() -> indie.Series[float]
NanToZero.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
NanToZero.calc()
method
Returns series created from src
by replacing math.nan
values with zeros.
calc(src: indie.Series[float]) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.SEE ALSO
NanToZero.new()
static method
Returns series created from src
by replacing math.nan
values with zeros.
new(src: indie.Series[float]) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.SEE ALSO
NetVolume.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
NetVolume.calc()
method
Returns series of Net Volume values calculated on src
series.
calc(src: indie.Series[float]) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.SEE ALSO
NetVolume.new()
static method
Returns series of Net Volume values calculated on src
series.
new(src: indie.Series[float]) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.SEE ALSO
PercentRank.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
PercentRank.calc()
method
Returns series of Percent Rank (number of previous values that are less or equal to the current value) calculated on src
series for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
PercentRank.new()
static method
Returns series of Percent Rank (number of previous values that are less or equal to the current value) calculated on src
series for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Rma.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Rma.calc()
method
Returns a Moving Average that is used in calculations of Rsi
.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Rma.new()
static method
Returns a Moving Average that is used in calculations of Rsi
.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Roc.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Roc.calc()
method
Returns series of Rate Of Change (percentage of change between the current value and value length
bars ago) calculated on src
series.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Roc.new()
static method
Returns series of Rate Of Change (percentage of change between the current value and value length
bars ago) calculated on src
series.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Rsi.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Rsi.calc()
method
Returns series of Relative Strength Index values calculated on src
series for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Rsi.new()
static method
Returns series of Relative Strength Index values calculated on src
series for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
SinceHighest.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
SinceHighest.calc()
method
Returns the number of bars after the maximum price for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
SinceHighest.new()
static method
Returns the number of bars after the maximum price for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
SinceLowest.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
SinceLowest.calc()
method
Returns the number of bars after the minimum price for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
SinceLowest.new()
static method
Returns the number of bars after the minimum price for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Sma.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Sma.calc()
method
Returns series of Simple Moving Average values calculated from series of src
for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Sma.new()
static method
Returns series of Simple Moving Average values calculated from series of src
for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
StdDev.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
StdDev.calc()
method
Returns series of Standard Deviation values calculated from series of src
for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
StdDev.new()
static method
Returns series of Standard Deviation values calculated from series of src
for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Stoch.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Stoch.calc()
method
Returns series of Stochastic on src
series with high
and low
highs and lows of the source over a period of length
bars.
calc(
src: indie.Series[float],
low: indie.Series[float],
high: indie.Series[float],
length: int
) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
low
— Series of low values.
high
— Series of high values.
length
— Number of bars in calculation taken into account.
SEE ALSO
Stoch.new()
static method
Returns series of Stochastic on src
series with high
and low
highs and lows of the source over a period of length
bars.
new(
src: indie.Series[float],
low: indie.Series[float],
high: indie.Series[float],
length: int
) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
low
— Series of low values.
high
— Series of high values.
length
— Number of bars in calculation taken into account.
SEE ALSO
Sum.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Sum.calc()
method
Returns series of Sliding Sum values calculated on src
series for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Sum.new()
static method
Returns series of Sliding Sum values calculated on src
series for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Supertrend.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Supertrend.calc()
method
Returns a tuple of two Supertrend series: Supertrend Line and Direction Of Trend.
calc(
factor: float,
atr_period: int,
ma_algorithm: str
) -> tuple[indie.Series[float], indie.Series[float]]
PARAMETERS
factor
— The multiplier by which the ATR will get multiplied.
atr_period
— Number of bars to calculate ATR.
ma_algorithm
— Moving average algorithm name, should be one of 'EMA'
, 'SMA'
, 'SMMA (RMA)'
, 'RMA'
, 'VWMA'
or 'WMA'
.
SEE ALSO
Supertrend.new()
static method
Returns a tuple of two Supertrend series: Supertrend Line and Direction Of Trend.
new(
factor: float,
atr_period: int,
ma_algorithm: str
) -> tuple[indie.Series[float], indie.Series[float]]
PARAMETERS
factor
— The multiplier by which the ATR will get multiplied.
atr_period
— Number of bars to calculate ATR.
ma_algorithm
— Moving average algorithm name, should be one of 'EMA'
, 'SMA'
, 'SMMA (RMA)'
, 'RMA'
, 'VWMA'
or 'WMA'
.
SEE ALSO
Tr.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Tr.calc()
method
Returns series of True Range values.
calc(handle_na: bool = False) -> indie.Series[float]
PARAMETERS
handle_na
— Flag that says how NaN
close values of the previous day are handled.SEE ALSO
Tr.new()
static method
Returns series of True Range values.
new(handle_na: bool = False) -> indie.Series[float]
PARAMETERS
handle_na
— Flag that says how NaN
close values of the previous day are handled.SEE ALSO
Tsi.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Tsi.calc()
method
Returns series of True Strength Index values.
calc(
src: indie.Series[float],
long_len: int,
short_len: int
) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
long_len
— Long length.
short_len
— Short length.
SEE ALSO
Tsi.new()
static method
Returns series of True Strength Index values.
new(
src: indie.Series[float],
long_len: int,
short_len: int
) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
long_len
— Long length.
short_len
— Short length.
SEE ALSO
Vwap.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Vwap.calc()
method
Returns series of Volume Weighted Average Price values with band of its standard deviation.
calc(
src: indie.Series[float],
anchor: str,
std_dev_mult: float
) -> tuple[indie.Series[float], indie.Series[float], indie.Series[float]]
PARAMETERS
src
— Series data to perform the calculation.
anchor
— At what points in time do we need to reset the accumulated amounts. Valid values are: 'day', 'week', 'month', 'year'.
std_dev_mult
— Multiplier for standard deviation.
SEE ALSO
Vwap.new()
static method
Returns series of Volume Weighted Average Price values with band of its standard deviation.
new(
src: indie.Series[float],
anchor: str,
std_dev_mult: float
) -> tuple[indie.Series[float], indie.Series[float], indie.Series[float]]
PARAMETERS
src
— Series data to perform the calculation.
anchor
— At what points in time do we need to reset the accumulated amounts. Valid values are: 'day', 'week', 'month', 'year'.
std_dev_mult
— Multiplier for standard deviation.
SEE ALSO
Vwma.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Vwma.calc()
method
Returns series of Volume Weighted Moving Average values calculated for src
series for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Vwma.new()
static method
Returns series of Volume Weighted Moving Average values calculated for src
series for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Wma.__init__()
method
Class constructor (initializer for the data type).
__init__(ctx: indie.Context) -> NoneType
PARAMETERS
ctx
— Context object.SEE ALSO
Wma.calc()
method
Returns series of Weighted Moving Average values calculated for src
series for the length
bars period.
calc(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
Wma.new()
static method
Returns series of Weighted Moving Average values calculated for src
series for the length
bars period.
new(src: indie.Series[float], length: int) -> indie.Series[float]
PARAMETERS
src
— Series data to perform the calculation.
length
— Number of bars in calculation taken into account.
SEE ALSO
indie.color
Class-container for builtin colors and rgba
function.
AQUA
BLACK
BLUE
FUCHSIA
GRAY
GREEN
LIME
MAROON
NAVY
OLIVE
PURPLE
RED
rgba()
SILVER
TEAL
WHITE
YELLOW
rgba()
function
Creates a Color
object by its RGB components and alpha channel.
rgba(red: int, green: int, blue: int, alpha: float = 1.0) -> indie.Color
PARAMETERS
red
— Red component of color.
green
— Green component of color.
blue
— Blue component of color.
alpha
— Alpha channel (component) of color which ranges from 0.0
(fully transparent) to 1.0
(fully opaque).
AQUA
object
Built-in color.
BLACK
object
Built-in color.
BLUE
object
Built-in color.
FUCHSIA
object
Built-in color.
GRAY
object
Built-in color.
GREEN
object
Built-in color.
LIME
object
Built-in color.
MAROON
object
Built-in color.
NAVY
object
Built-in color.
OLIVE
object
Built-in color.
PURPLE
object
Built-in color.
RED
object
Built-in color.
SILVER
object
Built-in color.
TEAL
object
Built-in color.
WHITE
object
Built-in color.
YELLOW
object
Built-in color.
math
Math package.
acos()
asin()
atan()
ceil()
cos()
e
exp()
exp2()
floor()
isclose()
isnan()
log()
log10()
log2()
nan
pi
pow()
sin()
sqrt()
tan()
See description in the official Python docs.
acos()
function
Standard function of Indie math package (similar to Python's).
acos(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
asin()
function
Standard function of Indie math package (similar to Python's).
asin(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
atan()
function
Standard function of Indie math package (similar to Python's).
atan(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
ceil()
function
Standard function of Indie math package (similar to Python's).
ceil(float) -> int
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
cos()
function
Standard function of Indie math package (similar to Python's).
cos(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
exp()
function
Standard function of Indie math package (similar to Python's).
exp(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
exp2()
function
Standard function of Indie math package (similar to Python's).
exp2(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
floor()
function
Standard function of Indie math package (similar to Python's).
floor(float) -> int
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
isclose()
function
Standard function of Indie math package (similar to Python's).
isclose(float, float, rel_tol: float = 1e-9, abs_tol: float = 0.0) -> bool
PARAMETERS
<unnamed param>
— First value to check for proximity.
<unnamed param>
— Second value to check for proximity.
rel_tol
— Relative tolerance for proximity check.
abs_tol
— Absolute tolerance for proximity check.
isnan()
function
Standard function of Indie math package (similar to Python's).
isnan(float) -> bool
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
log()
function
Standard function of Indie math package (similar to Python's).
log(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
log10()
function
Standard function of Indie math package (similar to Python's).
log10(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
log2()
function
Standard function of Indie math package (similar to Python's).
log2(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
pow()
function
Standard function of Indie math package (similar to Python's).
pow(float, float) -> float
PARAMETERS
<unnamed param>
— Base value to calculate exponentiation.
<unnamed param>
— Exponent (power) value to calculate exponentiation.
sin()
function
Standard function of Indie math package (similar to Python's).
sin(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
sqrt()
function
Standard function of Indie math package (similar to Python's).
sqrt(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
tan()
function
Standard function of Indie math package (similar to Python's).
tan(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
e
object
Standard constant of Indie math package (similar to Python's).
nan
object
Standard constant of Indie math package (similar to Python's).
pi
object
Standard constant of Indie math package (similar to Python's).
statistics
Statistics package.
See description in the official Python docs.
fmean()
function
Standard statistics function.
fmean(data: list[float]) -> float
PARAMETERS
data
— List on which the function will be calculated.
mean()
function
Standard statistics function.
mean(data: list[float]) -> float
mean(data: list[int]) -> float
PARAMETERS
data
— List on which the function will be calculated.
median()
function
Standard statistics function.
median(data: list[float]) -> float
PARAMETERS
data
— List on which the function will be calculated.
datetime
The datetime package supplies classes for manipulating dates and times.
See description in the official Python docs.
datetime
type
Represents date and time information.
__add__()
__init__()
__sub__()
day
hour
microsecond
minute
month
second
utcfromtimestamp()
weekday()
year
time
type
Represents a time of day, independent of any particular day.
__add__()
__init__()
__sub__()
hour
microsecond
minute
second
timedelta
type
A timedelta object represents a duration, the difference between two datetimes.
__init__()
days
microseconds
seconds
total_seconds()
datetime.__add__()
method
+
operator for datetime
objects.
__add__(delta: datetime.timedelta) -> datetime.datetime
PARAMETERS
delta
— Timedelta to add to the current datetime.SEE ALSO
datetime.__init__()
method
Class constructor (initializer for the data type).
__init__(
year: int,
month: int,
day: int,
hour: int = 0,
minute: int = 0,
second: int = 0,
microsecond: int = 0
) -> NoneType
PARAMETERS
year
— Year value.
month
— Month value.
day
— Day value.
hour
— Hour value.
minute
— Minute value.
second
— Second value.
microsecond
— Microsecond value.
SEE ALSO
datetime.__sub__()
method
-
operator for datetime
objects.
__sub__(delta: datetime.timedelta) -> datetime.datetime
__sub__(other: datetime.datetime) -> datetime.timedelta
PARAMETERS
delta
— Timedelta to subtract from the current datetime.
other
— Datetime to subtract from the current datetime.
SEE ALSO
datetime.utcfromtimestamp()
static method
Returns the UTC datetime corresponding to the POSIX timestamp.
utcfromtimestamp(timestamp: float) -> datetime.datetime
PARAMETERS
timestamp
— Timestamp in UTC.SEE ALSO
datetime.weekday()
method
Returns the day of the week as an integer, where Monday is 0 and Sunday is 6.
weekday() -> int
time.__add__()
method
+
operator for time
objects.
__add__(delta: datetime.timedelta) -> datetime.datetime
PARAMETERS
delta
— Timedelta to add to the current time.SEE ALSO
time.__init__()
method
Class constructor (initializer for the data type).
__init__(
hour: int = 0,
minute: int = 0,
second: int = 0,
microsecond: int = 0
) -> NoneType
PARAMETERS
hour
— Hour value.
minute
— Minute value.
second
— Second value.
microsecond
— Microsecond value.
SEE ALSO
time.__sub__()
method
-
operator for time
objects.
__sub__(delta: datetime.timedelta) -> datetime.datetime
PARAMETERS
delta
— Timedelta to subtract from the current time.SEE ALSO
timedelta.__init__()
method
Class constructor (initializer for the data type).
__init__(
days: int = 0,
seconds: int = 0,
microseconds: int = 0,
milliseconds: int = 0,
minutes: int = 0,
hours: int = 0,
weeks: int = 0
) -> NoneType
PARAMETERS
days
— Number of days.
seconds
— Number of seconds.
microseconds
— Number of microseconds.
milliseconds
— Number of milliseconds.
minutes
— Number of minutes.
hours
— Number of hours.
weeks
— Number of weeks.
SEE ALSO
timedelta.total_seconds()
method
Returns the total number of seconds contained in the duration.
total_seconds() -> float
datetime.day
field
The day value of the datetime object.
datetime.hour
field
The hour value of the datetime object.
datetime.microsecond
field
The microsecond value of the datetime object.
datetime.minute
field
The minute value of the datetime object.
datetime.month
field
The month value of the datetime object.
datetime.second
field
The second value of the datetime object.
datetime.year
field
The year value of the datetime object.
time.hour
field
The hour value of the time object.
time.microsecond
field
The microsecond value of the time object.
time.minute
field
The minute value of the time object.
time.second
field
The second value of the time object.
timedelta.days
field
The days value of the timedelta object.
timedelta.microseconds
field
The microseconds value of the timedelta object.
timedelta.seconds
field
The seconds value of the timedelta object.
NoneType
type
Builtin Indie type (similar to Python's None
type).
bool
type
Built-in Indie type (similar to Python's).
dict[K, V]
type
Built-in Indie type (similar to Python's).
float
type
Built-in Indie type (similar to Python's).
int
type
Built-in Indie type (similar to Python's).
list[T]
type
Built-in Indie type (similar to Python's).
__getitem__()
__len__()
__setitem__()
append()
pop()
remove()
# examples of list creation:
a = [1, 2, 3] # `a` has type `list[int]`
b = [1, 2, 3, 4.2] # `b` has type `list[float]`
c = ["a", "b", "c"] # `c` has type `list[str]`
d = [(1, "a"), (2, "b"), (3, "c")] # `d` has type `list[tuple[int, str]]`
e = [0, 1, 2, 3, 4, 5, 6, 7]
f = e[2:5] # `f` is `[2, 3, 4]`
g = e[:5] # `g` is `[0, 1, 2, 3, 4]`
h = e[2:] # `h` is `[2, 3, 4, 5, 6, 7]`
i = e[:] # `i` is a copy of `e`
j = e[1:7:2] # `j` is `[1, 3, 5]`
k = e[5:2:-1] # `k` is `[5, 4, 3]`
l = e[5::-1] # `l` is `[5, 4, 3, 2, 1, 0]`
m = e[::-1] # `m` is `[7, 6, 5, 4, 3, 2, 1, 0]`
str
type
Built-in Indie type (similar to Python's).
__bool__()
__init__()
__len__()
tuple[...]
type
Built-in Indie type (similar to Python's).
NoneType.__bool__()
method
Casts given none to bool.
__bool__() -> bool
abs()
function
Returns the absolute value of a number. It is a built-in Indie function (similar to Python's).
abs(int) -> int
abs(float) -> float
PARAMETERS
<unnamed param>
— Number on which the function will be calculated.
bool.__bool__()
method
Casts given bool to bool.
__bool__() -> bool
bool.__init__()
method
Cast constructor for built-in Indie type. Returns a bool
value, i.e. one of True
or False
. The argument is converted using the standard Python's truth testing procedure. If the argument is false or omitted, this returns False
; otherwise, it returns True
.
__init__(bool) -> NoneType
__init__(int) -> NoneType
__init__(float) -> NoneType
__init__(str) -> NoneType
__init__(NoneType) -> NoneType
__init__(indie.Optional[bool]) -> NoneType
__init__(indie.Optional[int]) -> NoneType
__init__(indie.Optional[float]) -> NoneType
__init__(indie.Optional[str]) -> NoneType
PARAMETERS
<unnamed param>
— Value to cast from.SEE ALSO
float.__bool__()
method
Casts given float to bool.
__bool__() -> bool
float.__init__()
method
Cast constructor for built-in Indie type. Returns a float
number constructed from a number or a string.
__init__(float) -> NoneType
__init__(int) -> NoneType
__init__(str) -> NoneType
__init__(bool) -> NoneType
PARAMETERS
<unnamed param>
— Value to cast from.SEE ALSO
int.__bool__()
method
Casts given int to bool.
__bool__() -> bool
int.__init__()
method
Cast constructor for built-in Indie type. Returns an int
object constructed from a number or a string, or return 0 if no arguments are given.
__init__(int) -> NoneType
__init__(float) -> NoneType
__init__(str) -> NoneType
__init__(bool) -> NoneType
PARAMETERS
<unnamed param>
— Value to cast from.SEE ALSO
len()
function
Returns the length (the number of items) of an object. It is a built-in Indie function (similar to Python's).
len(str) -> int
len(list[float]) -> int
len(list[int]) -> int
len(list[str]) -> int
len(indie.Series[float]) -> int
len(indie.MutSeries[float]) -> int
PARAMETERS
<unnamed param>
— String on which the function will be calculated.
<unnamed param>
— List on which the function will be calculated.
<unnamed param>
— Series on which the function will be calculated.
<unnamed param>
— MutSeriesF on which the function will be calculated.
list[T].__getitem__()
method
Returns list element at given index or slice.
__getitem__(int) -> T
__getitem__(slice) -> list[T]
PARAMETERS
<unnamed param>
— Index of an element in the list.
<unnamed param>
— Slice of elements in the list, similar to Python slices. Slices allow to specify a start and end index, as well as a step size, in the format [start:stop:step]. Any of the slice indices can be omitted. See more examples here.
EXAMPLE
nums = [40, 41, 42, 43]
meaning_of_life = nums[2] # returns 42 (this implicitly calls `nums.__getitem__(2)`)
Method __getitem__
should never be called directly, instead list_obj[key]
syntax should be used.
list[T].__len__()
method
Returns the length (the number of items) of a list[T].
__len__() -> int
nums = [40, 41, 42, 43]
len(nums) # returns 4 (this implicitly calls `nums.__len__()`)
Method __len__
should never be called directly, instead len(list_obj)
syntax should be used.
list[T].__setitem__()
method
Called to implement assignment to some_list[key].
__setitem__(int, T) -> NoneType
PARAMETERS
<unnamed param>
— Index of an element in the list.
<unnamed param>
— New value that will be put to the list.
EXAMPLE
nums = [40, 41, 42, 43]
nums[2] = 100500 # this implicitly calls `nums.__setitem__(2, 100500)`
# and now `nums` are [40, 41, 100500, 43]
Method __setitem__
should never be called directly, instead list_obj[key] = value
syntax should be used.
list[T].append()
method
Appends given param to the end of the list.
append(T) -> NoneType
PARAMETERS
<unnamed param>
— New value that will be put to the list.SEE ALSO
list[T].pop()
method
Retrieves the item at given index and also removes it from the list
pop(int) -> T
PARAMETERS
<unnamed param>
— Index of an element in the list.EXAMPLE
nums = [40, 41, 42, 43]
meaning_of_life = nums.pop(2) # now `nums` are [40, 41, 43], `meaning_of_life` is 42
list[T].remove()
method
Removes the first item from list s
where s[i]
is equal to given param.
remove(T) -> NoneType
PARAMETERS
<unnamed param>
— Value that will be removed from the listEXAMPLE
nums = [40, 41, 42, 40, 41, 42]
nums.remove(42) # now `nums` are [40, 41, 40, 41, 42]
max()
function
Returns the largest of two or more arguments. It is a built-in Indie function (similar to Python's).
max(int, int) -> int
max(int, int, int) -> int
max(float, float) -> float
max(float, float, float) -> float
PARAMETERS
<unnamed param>
— First number to calculate the function.
<unnamed param>
— Second number to calculate the function.
<unnamed param>
— Third number to calculate the function.
min()
function
Returns the smallest of two or more arguments. It is a built-in Indie function (similar to Python's).
min(int, int) -> int
min(int, int, int) -> int
min(float, float) -> float
min(float, float, float) -> float
PARAMETERS
<unnamed param>
— First number to calculate the function.
<unnamed param>
— Second number to calculate the function.
<unnamed param>
— Third number to calculate the function.
range()
function
Creates a list containing the specified range of numbers that is used in for
loops. It is a built-in Indie function (similar to Python's).
range(stop: int) -> list[int]
range(start: int, stop: int, step: int = 1) -> list[int]
PARAMETERS
stop
— Last value of the range (exclusive).
start
— First value of the range.
step
— Step value of the range.
EXAMPLE
x = 0
for i in range(10):
x += i
The behavior of this function is similar to Python's 2 built-in function range
and is ineffective. This will be fixed in future versions of Indie.
round()
function
Returns number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input. It is a built-in Indie function (similar to Python's).
round(number: float) -> int
round(number: float, ndigits: indie.Optional[int] = None) -> float
PARAMETERS
number
— Number on which the function will be calculated.
ndigits
— Rounding precision.
str.__bool__()
method
Casts given str to bool.
__bool__() -> bool
str.__init__()
method
Cast constructor for built-in Indie type. Returns a str
version of object.
__init__(int) -> NoneType
__init__(float) -> NoneType
__init__(str) -> NoneType
__init__(bool) -> NoneType
PARAMETERS
<unnamed param>
— Value to cast from.SEE ALSO
str.__len__()
method
Returns the length (the number of characters) of a str
.
__len__() -> int
s = 'foobar'
len(s) # returns 6 (this implicitly calls `s.__len__()`)
Method __len__
should never be called directly, instead len(str_obj)
syntax should be used.
sum()
function
Sums start and the items of a list from left to right and returns the total. It is a built-in Indie function (similar to Python's).
sum(list[int], start: int = 0) -> int
sum(list[float], start: float = 0.0) -> float
PARAMETERS
<unnamed param>
— List on which the function will be calculated.
start
— Initial value to calculate sum of the list.
tuple[...].__getitem__()
method
Returns tuple element at given index.
__getitem__(int) -> NoneType
PARAMETERS
<unnamed param>
— Index of an element in the tuple.REMARKS
Method __getitem__
should never be called directly, instead tuple_obj[key]
syntax should be used.
False
object
Built-in Indie object (similar to Python's).
None
object
Built-in Indie object (similar to Python's).
True
object
Built-in Indie object (similar to Python's).