Main package of Indie language.


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
@indicator('Band example')
@band(145, 155, line_color=color.RED, line_width=4)
def Main(self):
    return self.close[0]
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

Decorator that is used to create a level (horizontal line) in an indicator.

Example
@indicator('Level example')
@level(150, line_color=color.RED, line_width=4)
def Main(self):
    return self.close[0]
See also: @band()

@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
@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=TimeFrame.from_str('1D'), sec_context=SecMain)

    def calc(self):
        return self._calc_on_result[0]

param

type

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.

Example
@param.bool('is_something_enabled', default=False)
def Main(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.

Example
@param.int('meaning_of_life', default=42)
def Main(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.

Example
@param.float('speed_of_light', default=299_792.458)
def Main(self, speed_of_light):
    # Use speed_of_light variable...
@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.

Example
@param.str('name', default='Lisa', 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.
@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.

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.
See also: param source
@time_frame
(id, default, options, title) -> None

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
@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.
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
# indie:lang_version = 5
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.

Types

Algorithm

type

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).


Color

type

Data type to represent color.

Methods

__call__
(alpha) -> indie.Color

Creates a new Color instance with the given transparency applied to the existing color.

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.
See also: color

Context

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.

time_frame
indie.TimeFrame

Time frame of the context’s instrument.

trading_session
indie.schedule.TradingSession

Trading session of the context’s instrument.

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.
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).


IndieError

type

Data type for Indie errors.

Methods

__init__
(msg) -> None

Class constructor (initializer for the data type).


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.schedule.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.
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

MutSeriesF = MutSeries[float]

Parent

Methods

__setitem__
(i, x) -> None

Sets value of MutSeries[T] object at the specified index.

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.

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).

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
@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.
__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.

Optional[T]

type

Builtin Indie type (similar to Python’s typing.Optional).

Methods

value
() -> T

Returns value of indie.Optional[T] object. Raises a runtime error if the optional object is None.

value_or
(default) -> T

Returns value of indie.Optional[T] object or given default if the optional object is None.

__bool__
() -> bool

Casts Optional object to bool.

This method is present for Optional[T] only if T can be converted to bool.

__isnone__
() -> bool

Returns True if the optional value is None, otherwise False.

Example
my_val: Optional[int] = 4
my_bool = my_val is None
Method __isnone__ should never be called directly, instead val is None syntax should be used.

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.schedule.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.
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

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.

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
@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.
__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.

SymbolInfo

type

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.

timezone
str

Name of the exchange timezone of the context’s instrument. For example, 'America/New_York'.

See also: Context

TimeFrame

type

Data type that represents time frame.

Methods

__init__
(count, unit) -> None

Class constructor (initializer for the data type).

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.


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

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.

__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.

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.

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.

is_extended
(timestamp) -> bool

Determines whether a given timestamp falls within an extended trading session (either pre-market or after-hours).

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.

is_after_hours
(timestamp) -> bool

Determines whether a given timestamp falls within a after-hours trading session.


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.

Methods

get
() -> T

Returns value of Var[T] object.

set
(new_value) -> None

Sets value of Var[T] 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.


Enums

format

enum

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.

See also: @indicator()

line_style

enum

Enum-like class with constants of line styles.

Static fields

SOLID
indie.line_style

Built-in line style constant that determines how the line is rendered.

DASHED
indie.line_style

Built-in line style constant that determines how the line is rendered.

DOTTED
indie.line_style

Built-in line style constant that determines how the line is rendered.


source

enum

Enum-like class with constants for various price sources (it is used in @indie.param.source).

Static fields

OPEN
indie.source

Built-in source kind constant which corresponds to Context’s series field and is used to initialize source input parameter.

HIGH
indie.source

Built-in source kind constant which corresponds to Context’s series field and is used to initialize source input parameter.

LOW
indie.source

Built-in source kind constant which corresponds to Context’s series field and is used to initialize source input parameter.

CLOSE
indie.source

Built-in source kind constant which corresponds to Context’s series field and is used to initialize source input parameter.

VOLUME
indie.source

Built-in source kind constant which corresponds to Context’s series field and is used to initialize source input parameter.

HL2
indie.source

Built-in source kind constant which corresponds to Context’s series field and is used to initialize source input parameter.

HLC3
indie.source

Built-in source kind constant which corresponds to Context’s series field and is used to initialize source input parameter.

OHLC4
indie.source

Built-in source kind constant which corresponds to Context’s series field and is used to initialize source input parameter.

See also: @param.source()

time_frame_unit

enum

Enum-like class with constants for time frame units.

Static fields

MINUTE
indie.time_frame_unit

Built-in constants that represent time frame units.

HOUR
indie.time_frame_unit

Built-in constants that represent time frame units.

DAY
indie.time_frame_unit

Built-in constants that represent time frame units.

WEEK
indie.time_frame_unit

Built-in constants that represent time frame units.

MONTH
indie.time_frame_unit

Built-in constants that represent time frame units.

See also: TimeFrame