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.
Most of the functions in the indie.algorithms package are decorated with @indie.algorithm decorator. Read more about it in Series processors chapter.
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.
id1
str
required
Identifier of the first plot to which the fill is applied.
id2
str
required
Identifier of the second plot to which the fill is applied.
id
indie.Optional[str]
default:None
Identifier of the fill (auto generated).
title
indie.Optional[str]
default:None
Human readable title which is visible in the indicator’s Settings panel.
color
indie.Optional[indie.Color]
default:None
Color of the fill on a chart. This color can be overwritten if the fill is a multicolored one.
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.
id
indie.Optional[str]
default:None
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
indie.Optional[str]
default:None
Human readable title which is visible in the indicator’s Settings panel.
color
indie.Optional[indie.Color]
default:None
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
indie.plot_style
default:indie.plot_style.LINE
Determines how the plot data is rendered. It is represented as enum value of type plot_style.
line_style
indie.Optional[indie.line_style]
default:None
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
indie.Optional[int]
default:None
Width of the line. Could be only used in combination with plot_style.LINE, plot_style.STEPS or plot_style.HISTOGRAM.
continuous
indie.Optional[bool]
default:None
Whether the plot should be continuous when the indicator has NaN values. Could be only used in combination with plot_style.LINE.
base_value
indie.Optional[float]
default:None
Base value. Could be only used in combination with plot_style.HISTOGRAM or plot_style.COLUMNS.
rel_width
indie.Optional[float]
default:None
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 omitteddefMain(self):return self.open[0], self.high[0], self.low[0], self.close[0]
Class with decorators of indicator input parameters of various types.
Static methods
@bool
(id, default, title) -> None
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.
id
str
required
Name of Main function or class parameter bound to the input parameter.
default
bool
required
Default value for the parameter in settings pane.
title
indie.Optional[str]
default:None
Human readable title which is visible in the indicator’s Settings panel.
Example
@param.bool('is_something_enabled', default=False)defMain(self, is_something_enabled):# Use is_something_enabled variable...
@int
(id, default, min, max, step, title) -> None
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.
id
str
required
Name of Main function or class parameter bound to the input parameter.
default
int
required
Default value for the parameter in settings pane.
min
int
default:-1000000
Minimum value of the parameter.
max
int
default:1000000
Maximum value of the parameter.
step
int
default:1
Step between values of the parameter.
title
indie.Optional[str]
default:None
Human readable title which is visible in the indicator’s Settings panel.
Example
@param.int('meaning_of_life', default=42)defMain(self, meaning_of_life):# Use meaning_of_life variable...
@float
(id, default, min, max, step, title) -> None
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.
id
str
required
Name of Main function or class parameter bound to the input parameter.
default
float
required
Default value for the parameter in settings pane.
min
float
default:-1000000.0
Minimum value of the parameter.
max
float
default:1000000.0
Maximum value of the parameter.
step
float
default:0.1
Step between values of the parameter.
title
indie.Optional[str]
default:None
Human readable title which is visible in the indicator’s Settings panel.
Example
@param.float('speed_of_light', default=299_792.458)defMain(self, speed_of_light):# Use speed_of_light variable...
@string
(id, default, options, title) -> None
[Deprecated, use @indie.param.str instead] 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.
id
str
required
Name of Main function or class parameter bound to the input parameter.
default
str
required
Default value for the parameter in settings pane.
options
indie.Optional[list[str]]
default:None
List of the possible values of the parameter.
title
indie.Optional[str]
default:None
Human readable title which is visible in the indicator’s Settings panel.
Example
@param.string('name', default='Bart', options=['Homer','Marge','Bart','Lisa','Maggie'])defMain(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.
@str
(id, default, options, title) -> None
Declares a str 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.
id
str
required
Name of Main function or class parameter bound to the input parameter.
default
str
required
Default value for the parameter in settings pane.
options
indie.Optional[list[str]]
default:None
List of the possible values of the parameter.
title
indie.Optional[str]
default:None
Human readable title which is visible in the indicator’s Settings panel.
Example
@param.str('name', default='Lisa', options=['Homer','Marge','Bart','Lisa','Maggie'])defMain(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.
@source
(id, default, options, title) -> None
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.
id
str
required
Name of Main function or class parameter bound to the input parameter.
default
indie.source
default:source.CLOSE
Default value for the parameter in settings pane.
options
indie.Optional[list[indie.source]]
default:None
List of the possible values of the parameter.
title
indie.Optional[str]
default:None
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])defMain(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.
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.
id
str
required
Name of Main function or class parameter bound to the input parameter.
default
str
required
Default value for the parameter in settings pane.
options
indie.Optional[list[str]]
default:None
List of the possible values of the parameter.
title
indie.Optional[str]
default:None
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'])defMain(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.
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.
[deprecated] 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.
Base class for the classes that perform some processing of series data.
Fields
ctx
indie.Context
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.
Methods
__init__
(ctx) -> None
Class constructor (initializer for the data type).
Data type that represents an instrument with OHLCV series values and other related information.
Fields
time
indie.Series[float]
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.
open
indie.Series[float]
Series of ‘open’ prices of the context’s instrument.
high
indie.Series[float]
Series of ‘high’ prices of the context’s instrument.
low
indie.Series[float]
Series of ‘low’ prices of the context’s instrument.
close
indie.Series[float]
Series of ‘close’ prices of the context’s instrument.
volume
indie.Series[float]
Series of ‘volume’ values of the context’s instrument.
hl2
indie.Series[float]
Series of ‘(high + low) / 2’ values of the context’s instrument.
hlc3
indie.Series[float]
Series of ‘(high + low + close) / 3’ values of the context’s instrument.
ohlc4
indie.Series[float]
Series of ‘(open + high + low + close) / 4’ values of the context’s instrument.
info
indie.SymbolInfo
Information about the context’s instrument.
bar_index
int
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.
bar_count
int
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.
is_closed_bar
bool
Flag that is True if the current bar is a historical bar or it is a final update for a realtime bar.
is_history
bool
Flag that is True if the current bar is a historical bar.
is_last_bar
bool
Flag that is True if the current bar is the last bar in the history or it is a realtime bar.
is_last_history_bar
bool
Flag that is True if the current bar is the last bar of the historical part of prices data.
is_new_bar
bool
Flag that is True if the current bar is a historical bar or it is a first update for a realtime bar.
is_realtime
bool
Flag that is True if the last (current) bar is a realtime bar.
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.
sec_context
typing.Any
required
Function decorated with @indie.sec_context. This function has the same semantics as Indie Main, but for additional instrument (not the main one).
exchange
indie.Optional[str]
default:None
Alias for exchange of additional instrument. If omitted, then the exchange of the current context’s instrument will be used.
ticker
indie.Optional[str]
default:None
Ticker of an additional instrument. If omitted, then the ticker of the current context’s instrument will be used.
time_frame
indie.Optional[indie.TimeFrame]
default:None
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
bool
default:False
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.
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.
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).
default
indie.Optional[float]
default:None
Default value that will be used if an element at the specified index cannot be extracted.
size
int
default:2
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.
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).
default
T
required
Default value that will be used if an element at the specified index cannot be extracted.
size
int
default:2
Number of elements that MutSeries 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. MutSeries objects also have a method request_size(new_size: int) which can be used to expand the size explicitly.
new_var
(init) -> indie.Var[T]
Creates a Var[T] object, which is a container for T value in Indie code. The main feature of the Var[T] container is its ability to rollback the value of the variable when a new realtime update appears to its value after the previous bar.
init
T
required
Value that is written into Var object only once after the Var object was created.
is_first_in_session
() -> bool
Detects whether the current bar is the first bar of a new trading session (extended session included). Returns True if the current bar is the first bar of the trading session or False if the current bar is not the first in the session or if no session has started.
The function will return False if the first bar of the session does not exist or is unavailable (e.g., due to data gaps or missing information).
is_first_in_regular_session
() -> bool
Detects whether the current bar is the first bar of the regular trading session (excluding pre-market session). Returns True if the current bar is the first bar of the regular trading session or False if the current bar is not the first in the regular session or if no session has started.
The function will return False if the first bar of the regular session does not exist or is unavailable (e.g., due to data gaps or missing information).
is_last_in_session
() -> bool
Detects whether the current bar is the last bar of the trading session (extended session included). Returns True if the current bar is the last bar of the trading session or False if the current bar is not the last in the session.
The function will return False if the session ends without a valid last bar (e.g., due to missing data).
is_last_in_regular_session
() -> bool
Detects whether the current bar is the last bar of the regular trading session (excluding after-hours session). Returns True if the current bar is the last bar of the regular trading session or False if the current bar is not the last in the regular session.
The function will return False if the session ends without a valid last bar (e.g., due to missing data).
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.
open
indie.Series[float]
Series of ‘open’ prices of the context’s instrument.
high
indie.Series[float]
Series of ‘high’ prices of the context’s instrument.
low
indie.Series[float]
Series of ‘low’ prices of the context’s instrument.
close
indie.Series[float]
Series of ‘close’ prices of the context’s instrument.
volume
indie.Series[float]
Series of ‘volume’ values of the context’s instrument.
hl2
indie.Series[float]
Series of ‘(high + low) / 2’ values of the context’s instrument.
hlc3
indie.Series[float]
Series of ‘(high + low + close) / 3’ values of the context’s instrument.
ohlc4
indie.Series[float]
Series of ‘(open + high + low + close) / 4’ values of the context’s instrument.
info
indie.SymbolInfo
Information about the context’s instrument.
bar_index
int
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.
bar_count
int
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.
is_closed_bar
bool
Flag that is True if the current bar is a historical bar or it is a final update for a realtime bar.
is_history
bool
Flag that is True if the current bar is a historical bar.
is_last_bar
bool
Flag that is True if the current bar is the last bar in the history or it is a realtime bar.
is_last_history_bar
bool
Flag that is True if the current bar is the last bar of the historical part of prices data.
is_new_bar
bool
Flag that is True if the current bar is a historical bar or it is a first update for a realtime bar.
is_realtime
bool
Flag that is True if the last (current) bar is a realtime bar.
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.
sec_context
typing.Any
required
Function decorated with @indie.sec_context. This function has the same semantics as Indie Main, but for additional instrument (not the main one).
exchange
indie.Optional[str]
default:None
Alias for exchange of additional instrument. If omitted, then the exchange of the current context’s instrument will be used.
ticker
indie.Optional[str]
default:None
Ticker of an additional instrument. If omitted, then the ticker of the current context’s instrument will be used.
time_frame
indie.Optional[indie.TimeFrame]
default:None
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
bool
default:False
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.
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.
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).
default
indie.Optional[float]
default:None
Default value that will be used if an element at the specified index cannot be extracted.
size
int
default:2
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.
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).
default
T
required
Default value that will be used if an element at the specified index cannot be extracted.
size
int
default:2
Number of elements that MutSeries 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. MutSeries objects also have a method request_size(new_size: int) which can be used to expand the size explicitly.
new_var
(init) -> indie.Var[T]
Creates a Var[T] object, which is a container for T value in Indie code. The main feature of the Var[T] container is its ability to rollback the value of the variable when a new realtime update appears to its value after the previous bar.
init
T
required
Value that is written into Var object only once after the Var object was created.
is_first_in_session
() -> bool
Detects whether the current bar is the first bar of a new trading session (extended session included). Returns True if the current bar is the first bar of the trading session or False if the current bar is not the first in the session or if no session has started.
The function will return False if the first bar of the session does not exist or is unavailable (e.g., due to data gaps or missing information).
is_first_in_regular_session
() -> bool
Detects whether the current bar is the first bar of the regular trading session (excluding pre-market session). Returns True if the current bar is the first bar of the regular trading session or False if the current bar is not the first in the regular session or if no session has started.
The function will return False if the first bar of the regular session does not exist or is unavailable (e.g., due to data gaps or missing information).
is_last_in_session
() -> bool
Detects whether the current bar is the last bar of the trading session (extended session included). Returns True if the current bar is the last bar of the trading session or False if the current bar is not the last in the session.
The function will return False if the session ends without a valid last bar (e.g., due to missing data).
is_last_in_regular_session
() -> bool
Detects whether the current bar is the last bar of the regular trading session (excluding after-hours session). Returns True if the current bar is the last bar of the regular trading session or False if the current bar is not the last in the regular session.
The function will return False if the session ends without a valid last bar (e.g., due to missing data).
Sets value of MutSeries[T] object at the specified index.
i
int
required
Index to assign value at.
x
T
required
New value.
Example
ms = MutSeries[float].new(init=0)ms[0]=42# This implicitly calls `ms.__setitem__(0, 42)`
(1) The index must be equal to 0 (because historical values cannot be updated), otherwise the function will raise an error at runtime. Yes, this looks very weird and maybe it would be much better just to have a method 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.
calc
(reset, init, size) -> indie.MutSeries[T]
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.
reset
indie.Optional[T]
default:None
Value that is written into the most recent element of the MutSeries every time MutSeries.new function is executed.
init
indie.Optional[T]
default:None
Value that is written into the most recent element of the MutSeries object only once after the MutSeries object was created.
size
int
default:2
Number of elements that MutSeries 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. MutSeries objects also have a method request_size(new_size: int) which can be used to expand the size explicitly.
Static methods
new
(reset, init, size) -> indie.MutSeries[T]
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).
reset
indie.Optional[T]
default:None
Value that is written into the most recent element of the MutSeries every time MutSeries.new function is executed.
init
indie.Optional[T]
default:None
Value that is written into the most recent element of the MutSeries object only once after the MutSeries object was created.
size
int
default:2
Number of elements that MutSeries 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. MutSeries objects also have a method request_size(new_size: int) which can be used to expand the size explicitly.
Returns value of Series[T] object at the specified index or given default if the value is missing.
offset
int
required
Offset to extract value at.
default
T
required
Default value that will be used if an element at the specified index cannot be extracted.
neg_offset_ok
bool
default:False
If False then get method raises an error on any offset < 0. If True then get method returns default value on negative offsets too. Default value is False.
request_size
(size) -> None
Expands the capacity of Series[T] object (number of elements that Series[T] object should store in memory).
size
int
required
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.
__getitem__
(i) -> T
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).
i
int
required
Index to extract value at.
Example
@indicator('Example')defMain(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.
__len__
() -> int
Returns length (number of elements) of a Series[T] object.
Example
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 of timestamps (as unix time UTC seconds) of the context’s instrument. Every timestamp corresponds to start time of some bar on a chart.
open
indie.Series[float]
Series of ‘open’ prices of the context’s instrument.
high
indie.Series[float]
Series of ‘high’ prices of the context’s instrument.
low
indie.Series[float]
Series of ‘low’ prices of the context’s instrument.
close
indie.Series[float]
Series of ‘close’ prices of the context’s instrument.
volume
indie.Series[float]
Series of ‘volume’ values of the context’s instrument.
hl2
indie.Series[float]
Series of ‘(high + low) / 2’ values of the context’s instrument.
hlc3
indie.Series[float]
Series of ‘(high + low + close) / 3’ values of the context’s instrument.
ohlc4
indie.Series[float]
Series of ‘(open + high + low + close) / 4’ values of the context’s instrument.
info
indie.SymbolInfo
Information about the context’s instrument.
bar_index
int
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.
bar_count
int
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.
is_closed_bar
bool
Flag that is True if the current bar is a historical bar or it is a final update for a realtime bar.
is_history
bool
Flag that is True if the current bar is a historical bar.
is_last_bar
bool
Flag that is True if the current bar is the last bar in the history or it is a realtime bar.
is_last_history_bar
bool
Flag that is True if the current bar is the last bar of the historical part of prices data.
is_new_bar
bool
Flag that is True if the current bar is a historical bar or it is a first update for a realtime bar.
is_realtime
bool
Flag that is True if the last (current) bar is a realtime bar.
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.
sec_context
typing.Any
required
Function decorated with @indie.sec_context. This function has the same semantics as Indie Main, but for additional instrument (not the main one).
exchange
indie.Optional[str]
default:None
Alias for exchange of additional instrument. If omitted, then the exchange of the current context’s instrument will be used.
ticker
indie.Optional[str]
default:None
Ticker of an additional instrument. If omitted, then the ticker of the current context’s instrument will be used.
time_frame
indie.Optional[indie.TimeFrame]
default:None
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
bool
default:False
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.
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.
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).
default
indie.Optional[float]
default:None
Default value that will be used if an element at the specified index cannot be extracted.
size
int
default:2
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.
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).
default
T
required
Default value that will be used if an element at the specified index cannot be extracted.
size
int
default:2
Number of elements that MutSeries 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. MutSeries objects also have a method request_size(new_size: int) which can be used to expand the size explicitly.
new_var
(init) -> indie.Var[T]
Creates a Var[T] object, which is a container for T value in Indie code. The main feature of the Var[T] container is its ability to rollback the value of the variable when a new realtime update appears to its value after the previous bar.
init
T
required
Value that is written into Var object only once after the Var object was created.
is_first_in_session
() -> bool
Detects whether the current bar is the first bar of a new trading session (extended session included). Returns True if the current bar is the first bar of the trading session or False if the current bar is not the first in the session or if no session has started.
The function will return False if the first bar of the session does not exist or is unavailable (e.g., due to data gaps or missing information).
is_first_in_regular_session
() -> bool
Detects whether the current bar is the first bar of the regular trading session (excluding pre-market session). Returns True if the current bar is the first bar of the regular trading session or False if the current bar is not the first in the regular session or if no session has started.
The function will return False if the first bar of the regular session does not exist or is unavailable (e.g., due to data gaps or missing information).
is_last_in_session
() -> bool
Detects whether the current bar is the last bar of the trading session (extended session included). Returns True if the current bar is the last bar of the trading session or False if the current bar is not the last in the session.
The function will return False if the session ends without a valid last bar (e.g., due to missing data).
is_last_in_regular_session
() -> bool
Detects whether the current bar is the last bar of the regular trading session (excluding after-hours session). Returns True if the current bar is the last bar of the regular trading session or False if the current bar is not the last in the regular session.
The function will return False if the session ends without a valid last bar (e.g., due to missing data).
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.
Aliases
SeriesF = Series[float]
Methods
get
(offset, default, neg_offset_ok) -> T
Returns value of Series[T] object at the specified index or given default if the value is missing.
offset
int
required
Offset to extract value at.
default
T
required
Default value that will be used if an element at the specified index cannot be extracted.
neg_offset_ok
bool
default:False
If False then get method raises an error on any offset < 0. If True then get method returns default value on negative offsets too. Default value is False.
request_size
(size) -> None
Expands the capacity of Series[T] object (number of elements that Series[T] object should store in memory).
size
int
required
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.
__getitem__
(i) -> T
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).
i
int
required
Index to extract value at.
Example
@indicator('Example')defMain(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.
__len__
() -> int
Returns length (number of elements) of a Series[T] object.
Example
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.
Data type to represent information about the context’s instrument.
Fields
ticker
str
Ticker of the context’s instrument.
exchange_code
str
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'.
exchange_aliases
list[str]
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).
price_precision
int
Price precision of the context’s instrument. For example, price precision of 100 means that prices have two digits after the floating point.
tick_size
float
Absolute value of a minimal movement of a price of the context’s instrument in corresponding currency.
marketdata_timezone
str
[deprecated] Name of the exchange timezone of the context’s instrument. For example, 'America/New_York'.
timezone
str
Name of the exchange timezone of the context’s instrument. For example, 'America/New_York'.
Class constructor (initializer for the data type).
count
int
required
Numeric part of time frame.
unit
indie.time_frame_unit
required
Unit of time frame, can be ‘m’, ‘h’, ‘D’, ‘W’ or ‘M’.
to_minutes
() -> int
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.
Static methods
from_str
(tf_str) -> indie.TimeFrame
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 TimeFrame.from_str('15m') creates a TimeFrame object which corresponds to 15 minute time frame.
Data type to represent different trading periods within a day, including pre-market, regular, and after-hours sessions. Each period is defined by its own schedule.
Fields
pre_market
indie.schedule.Schedule
Schedule instance that defines the rules and exceptions for the pre-market trading session.
regular
indie.schedule.Schedule
Schedule instance that defines the rules and exceptions for the regular trading session.
after_hours
indie.schedule.Schedule
Schedule instance that defines the rules and exceptions for the after-hours trading session.
extended
indie.schedule.Schedule
Schedule instance that defines the rules and exceptions for the extended session (pre-market + after-hours).
Methods
__contains__
(t) -> bool
Checks whether a given timestamp falls within the defined trading session. Returns True if the timestamp falls within the trading session’s active periods, otherwise returns False.
t
float
required
Timestamp to check in defined trading session.
__contains__
(d) -> bool
Checks whether a given timestamp falls within the defined trading session. Returns True if the timestamp falls within the trading session’s active periods, otherwise returns False.
d
datetime.datetime
required
Datetime to check in defined trading session.
is_same_period
(timestamp1, timestamp2) -> bool
Determines whether two timestamps fall within the same trading session period on the same day. Returns True if both timestamps fall within the same period of the trading session, even if they are in different calendar days. False if the timestamps belong to different periods within the trading session.
timestamp1
float
required
First timestamp to check.
timestamp2
float
required
Second timestamp to check.
This method checks if two timestamps, which may belong to different calendar days, are part of the same trading session period. It handles cases where a trading session spans across two consecutive days (e.g., a trading schedule that extends past midnight) and ensures both timestamps belong to the same logical period within the schedule.
is_regular
(timestamp) -> bool
Determines whether a given timestamp falls within a regular trading session.
timestamp
float
required
Timestamp to check against the specific part of trading sessions.
is_extended
(timestamp) -> bool
Determines whether a given timestamp falls within an extended trading session (either pre-market or after-hours).
timestamp
float
required
Timestamp to check against the specific part of trading sessions.
Returns True if the provided timestamp falls within either the pre-market or after-hours session. Returns False otherwise.
is_pre_market
(timestamp) -> bool
Determines whether a given timestamp falls within a pre-market trading session.
timestamp
float
required
Timestamp to check against the specific part of trading sessions.
is_after_hours
(timestamp) -> bool
Determines whether a given timestamp falls within a after-hours trading session.
timestamp
float
required
Timestamp to check against the specific part of trading sessions.
Generic data type that represents a rollbackable container for value of type T. Type T could be float, int, str, or almost any other type.
Methods
get
() -> T
Returns value of Var[T] object.
set
(new_value) -> None
Sets value of Var[T] object.
new_value
T
required
New value that will be put to Var object.
Static methods
new
(init) -> indie.Var[T]
Creates a Var[T] object, which is a container for T value in Indie code. The main feature of the Var[T] container is its ability to rollback the value of the variable when a new realtime update appears to its value after the previous bar.
init
T
required
Value that is written into Var object only once after the Var object was created.
Enum-like class with constants that determine how to format the indicator value on the price scale.
Static fields
INHERITED
indie.format
Indicator output values are formatted same as values of the main chart instrument.
PRICE
indie.format
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.
VOLUME
indie.format
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.