Decorators
@algorithm()
decorator
Overloads
@algorithm
() -> None
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.See also:
Algorithm
@band()
decorator
Overloads
@band
(value1, value2, title, fill_color, line_color, line_style, line_width) -> None
Use this decorator to add a band (two horizontal lines usually with a semi-transparent fill in between them) to indicator.
Example
See also:
@level()
@indicator()
decorator
Overloads
@indicator
(abbrev_title, overlay_main_pane, format, precision) -> None
Decorator that should be applied to the
Main
entry point of any indicator.See also:
@sec_context()
@level()
decorator
Overloads
@level
(value, title, line_color, line_style, line_width) -> None
@param_ref()
decorator
Overloads
@param_ref
(id) -> None
Declares an input parameter for
@sec_context
function that is linked to the input parameter of Main
by id
.Example
See also:
@sec_context()
param
param
type
Class with decorators of indicator input parameters of various types.
Static methods
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.Example
If
options
parameter is used then in Settings panel there will be a combobox widget for changing value of this input.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.Example
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.Example
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.See also:
TimeFrame
@sec_context()
decorator
Overloads
@sec_context
() -> None
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.Example
More info on this topic you can find in Request additional instruments chapter.
Types
Algorithm
type
Base class for the classes that perform some processing of series data.
Fields
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.Color
type
Data type to represent color.
See also:
color
Context
type
Data type that represents an instrument with OHLCV series values and other related information.
Fields
Methods
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.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.See also:
@sec_context()
SecContext
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).See also:
MutSeriesF
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).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).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).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).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).IndieError
type
Data type for Indie errors.
MainContext
type
Base class for the class that represents main context.
Parent
Inherited 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.time_frame
indie.TimeFrame
Time frame of the context’s instrument.
trading_session
indie.TradingSession
Trading session of the context’s instrument.
Inherited methods
calc_on
(sec_context, exchange, ticker, time_frame, *, lookahead) -> indie.SeriesF | tuple[indie.SeriesF, ...]
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.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.See also:
@sec_context()
SecContext
new_mut_series_f
(default, size) -> indie.MutSeries[float]
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).See also:
MutSeriesF
new_mut_series
(default, 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).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.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).MutSeries[T]
type
Generic data type that represents read-write series of values of type T
. Type T
can be float, int, str, or almost any other type.
Aliases
Parent
Methods
Sets value of
MutSeries[T]
object at the specified index.Example
(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.Static methods
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).See also:
Context.new_mut_series()
Inherited 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.request_size
(size) -> None
Expands the capacity of
Series[T]
object (number of elements that Series[T]
object should store in memory).__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).Example
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
Method
__len__
should never be called directly. Instead syntax len(series_obj)
should be used.See also:
Context.new_mut_series()
Series[T]
Optional[T]
type
Builtin Indie type (similar to Python’s typing.Optional
).
Methods
__init__
() -> None
Class constructor (initializer for the data type).
SecContext
type
Base class for the classes that represent additional contexts besides the main one.
Parent
Inherited 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.time_frame
indie.TimeFrame
Time frame of the context’s instrument.
trading_session
indie.TradingSession
Trading session of the context’s instrument.
Inherited methods
calc_on
(sec_context, exchange, ticker, time_frame, *, lookahead) -> indie.SeriesF | tuple[indie.SeriesF, ...]
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.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.See also:
@sec_context()
SecContext
new_mut_series_f
(default, size) -> indie.MutSeries[float]
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).See also:
MutSeriesF
new_mut_series
(default, 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).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.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[T]
type
Generic data type that represents read only series of values of type T
. Type T
can be float, int, str, or almost any other type.
Aliases
Methods
See also:
MutSeries[T]
Context
SymbolInfo
type
Data type to represent information about the context’s instrument.
Fields
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'
.See also:
Context
TimeFrame
type
Data type that represents time frame.
Static methods
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.TradingSession
type
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
Methods
__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
.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.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.
Var[T]
type
Generic data type that represents a rollbackable container for value of type T
. Type T
can be float, int, str, or almost any other type.
See also:
Context.new_var()
MutSeries[T]
Enums
format
enum
Enum-like class with constants that determine how to format the indicator value on the price scale.
Static fields
See also:
@indicator()
line_style
enum
Enum-like class with constants of line styles.
source
enum
Enum-like class with constants for various price sources (it is used in @indie.param.source
).
Static fields
See also:
@param.source()
time_frame_unit
enum
Enum-like class with constants for time frame units.
Static fields
See also:
TimeFrame