Skip to content

indicators

indicators

Modules:

Name Description
PPO
PSAR
adx
amorph
ao
aroon
atr
bandwidth
bbands
cci
chandelier_exit
cksp
cmf
cmo
coppock
counter
dema
donchian
ema
fisher
highest_lowest
hla
hlca
hma
ichimoku
jma
kama
kc
kst
linear_regression
macd
mfi
midpoint
natr
obv
pivot_points
regression_channel
regression_slope
rma
roc
rsi
rvi
sma
squeeze
squeeze_pro
stdev
stdevthres
stoch
supertrend
tema
tr
trix
tsi
uo
vortex
vwap
vwma
willr
wma
zscore

Classes:

Name Description
ADX

Average Directional Index - ADX

AO

Awesome Oscillator - AO

AROON

Aroon - AROON

ATR

Average True Range - ATR

Amorph

Amorph

BBANDS

Bollinger Bands - BBANDS

BandWidth

Bollinger BandWidth - BBB

CCI

Commodity Channel Index - CCI

CKSP

Chande Kroll Stop - CKSP

CMF

Chaikin Money Flow - CMF

CMO

Chande Momentum Oscillator - CMO

COPC

Coppock Curve - COPC

ChandelierExit

Chandelier Exit

Counter

Counter

DEMA

Double Exponential Moving Average - DEMA

Donchian

Donchian Channels - Donchian

EMA

Exponential Moving Average - EMA

Fisher

Fisher Transform - FISHERT

HL

Highest Lowest - HL

HLA

High Low Average - HLA

HLCA

High Low Close Average - HLCA

HMA

Hull Moving Average - HMA

Ichimoku

Ichimoku Kinko Hyo - ICHIMOKU

JMA

Jurik Moving Average Average - JMA

KAMA

Kaufman's Adaptive Moving Average - KAMA

KC

Keltner Channel - KC

KST

Know Sure Thing - KST

LinearRegression

Linear Regression - LR

MACD

Moving Average Convergence Divergence - MACD

MFI

Money Flow Index - MFI

MOP

Midpoint Over Period - MOP

NATR

Normalized Average True Range - NATR

OBV

On-Balance Volume - OBC

PivotPoints

Pivot Points - PP

RMA

wildeR's Moving Average - RMA

ROC

Rate Of Change - ROC

RSI

Relative Strength Index - RSI

RVI

Relative Vigor Index - RVI

RegressionChannel

Regression Channel

RegressionSlope

Regression Slope - LRm

SMA

Simple Moving Average - SMA

STDEV

Rolling Standard Deviation - STDEV

STDEVT

Standard Deviation Threshold - STDEVT

STOCH

Stochastic - STOCH

Squeeze

Squeeze

SqueezePro

SqueezePro

Supertrend

Supertrend

TEMA

Triple Exponential Moving Average - TEMA

TR

True Range - TR

TRIX

Triple Exponential Average Oscillator - TRIX

TSI

True Strength Index - TSI

UO

Ultimate Oscillator - UO

VWAP

Volume-Weighted Average Price - VWAP

VWMA

Volume Weighted Moving Average - VWMA

Vortex

Vortex Indicator - VTX

WMA

Weighted Moving Average - WMA

WillR

William's Percent R - WILLR

ZScore

Rolling Z Score - ZS

ADX dataclass

ADX(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    period_signal: int = 0,
    multiplier: float = 100.0
)

Bases: Indicator[dict[str, float | None]]

Average Directional Index - ADX

ADX is a trend strength in a series of prices of a financial instrument.

Sources

https://en.wikipedia.org/wiki/Average_directional_movement_index

Output type: Dict["ADX": float, "DM_Plus": float, "DM_Neg": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
period_signal Optional[int]

Average Directional Index period. Defaults same as period

0
multiplier float | None

ADX smoothing multiplier. Defaults to 100.0

100.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

AO dataclass

AO(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    fast: int = 5,
    slow: int = 34
)

Bases: Indicator[float | None]

Awesome Oscillator - AO

Awesome Oscillator compares a fast and slow simple moving average of the median price.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.ao.html

Output type: float

Parameters:

Name Type Description Default
fast int

Fast SMA length. Defaults to 5.

5
slow int

Slow SMA length. Defaults to 34.

34

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

AROON dataclass

AROON(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14
)

Bases: Indicator[dict[str, float | None]]

Aroon - AROON

The Aroon indicator, indicates if a price is trending or is in a trading range. It can also reveal the beginning of a new trend, its strength and can help anticipate changes from trading ranges to trends.

Sources

https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/aroon-indicator

Output type: Dict["AROONU": float, "AROOND": float, "AROONOSC": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

ATR dataclass

ATR(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14
)

Bases: Indicator[float | None]

Average True Range - ATR

Average True Range is used to measure volatility, especially volatility caused by gaps or limit moves.

Sources

https://www.tradingview.com/wiki/Average_True_Range_(ATR)

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Amorph

Amorph(analysis: Callable, args: dict | None = None, **kwargs)

Bases: Indicator

Amorph

Flexible Skeleton Indicator that will use a method to generate readings on every Candle like indicators.

The given Method is expected to have 'candles' and 'index' as named arguments, EG:

Input type Example: Doji

Output type: Based on analysis method

Parameters:

Name Type Description Default
analysis Callable

Period to index back in

required
args dict | None

All of the Arguments as keyword arguments as a dict of keyword arguments for called analysis

None

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Returns a dict format of how this indicator can be generated

Source code in hexital/indicators/amorph.py
def __init__(self, analysis: Callable, args: dict | None = None, **kwargs):
    self._analysis_method = analysis
    self.analysis_name = analysis.__name__
    self._analysis_kwargs, kwargs = self._separate_indicator_attributes(kwargs)

    if isinstance(args, dict):
        self._analysis_kwargs.update(args)

    super().__init__(**kwargs)

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Returns a dict format of how this indicator can be generated

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

BBANDS dataclass

BBANDS(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 5,
    source: Source = "close",
    std: float = 2.0
)

Bases: Indicator[dict[str, float | None]]

Bollinger Bands - BBANDS

Bollinger Bands are a type of statistical chart characterizing the prices and volatility over time of a financial instrument or commodity, using a formulaic method.

Sources

https://www.britannica.com/money/bollinger-bands-indicator

Output type: Dict["BBL": float, "BBM": float, "BBU": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 5

5
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

BandWidth dataclass

BandWidth(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 5,
    source: Source = "close",
    std: float = 2.0
)

Bases: Indicator[float | None]

Bollinger BandWidth - BBB

BandWidth expresses the Bollinger Band spread relative to the middle band.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/volatility/help/pandas_ta.volatility.bbands.html

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 5.

5
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'
std float

Standard deviation multiplier. Defaults to 2.0.

2.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

CCI dataclass

CCI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close",
    scaling: float = 0.015
)

Bases: Indicator[float | None]

Commodity Channel Index - CCI

The Commodity Channel Index measures the current typical price relative to its rolling mean and mean absolute deviation over a fixed lookback period. It is commonly used to identify overbought, oversold, and trend deviation conditions.

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 14

14
source str

Which input field to calculate the indicator from. Defaults to "close"

'close'
c float

Constant scaling factor applied to the mean absolute deviation. Defaults to 0.015

required

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

CKSP dataclass

CKSP(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    multiplier: float = 3.0,
    smooth_period: int = 20,
    tvmode: bool = True
)

Bases: Indicator[dict[str, float | None]]

Chande Kroll Stop - CKSP

CKSP builds trailing stop bands from ATR and then smooths those raw stop levels with rolling extrema.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/trend/help/pandas_ta.trend.cksp.html

Output type: Dict["long": float, "short": float]

Parameters:

Name Type Description Default
period int

ATR and primary stop lookback. Defaults to 10. pandas_ta alias: p

10
multiplier float

ATR multiplier. Defaults to 3.0. pandas_ta alias: x

3.0
smooth_period int

Secondary smoothing lookback. Defaults to 20. pandas_ta alias: q

20
tvmode bool

Use TradingView ATR smoothing mode. Defaults to True.

True

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

CMF dataclass

CMF(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 20
)

Bases: Indicator[float | None]

Chaikin Money Flow - CMF

Chaikin Money Flow measures buying and selling pressure by comparing rolling money flow volume against rolling total volume.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/volume/help/pandas_ta.volume.cmf.html

Output type: float

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 20.

20

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

CMO dataclass

CMO(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Chande Momentum Oscillator - CMO

The CMO indicator is created by calculating the difference between the sum of all recent higher closes and the sum of all recent lower closes and then dividing the result by the sum of all price movement over a given time period. The result is multiplied by 100 to give the -100 to +100 range.

Sources

https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/cmo

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

COPC dataclass

COPC(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    fast: int = 11,
    slow: int = 14
)

Bases: Indicator[float | None]

Coppock Curve - COPC

Coppock Curve is a weighted moving average of the sum of two rate-of-change series.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.coppock.html

Output type: float

Parameters:

Name Type Description Default
period int

WMA smoothing length. Defaults to 10.

10
fast int

Fast ROC length. Defaults to 11.

11
slow int

Slow ROC length. Defaults to 14.

14

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

ChandelierExit dataclass

ChandelierExit(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 22,
    multiplier: float = 3.0
)

Bases: Indicator[dict[str, float | None]]

Chandelier Exit

Chandelier Exit places trailing stop levels below the rolling high and above the rolling low using an ATR multiple.

Sources

https://chartschool.stockcharts.com/table-of-contents/technical-indicators-and-overlays/technical-overlays/chandelier-exit

Output type: Dict["long": float, "short": float]

Parameters:

Name Type Description Default
period int

Lookback and ATR period. Defaults to 22.

22
multiplier float

ATR multiple. Defaults to 3.0.

3.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Counter dataclass

Counter(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    source: Source,
    count_value: Any = True
)

Bases: Indicator[int]

Counter

Simple Indictor which will count the current streak of a given value, specifically designed for bool values, but useable on any other re-occurring values. E.G Count the streak for current input value == count_value

Output type: float

Parameters:

Name Type Description Default
source str

Which input field to calculate the Indicator.

required
count_value bool | int

Which value to be counting, E.G bool, 1, etc

True

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

DEMA dataclass

DEMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Double Exponential Moving Average - DEMA

DEMA reduces lag versus a standard EMA by combining an EMA with an EMA of that EMA.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.dema.html

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 10.

10
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Donchian dataclass

Donchian(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 20
)

Bases: Indicator[dict[str, float | None]]

Donchian Channels - Donchian

Donchian Channels are a technical indicator that seeks to identify bullish and bearish extremes that favor reversals, higher and lower breakouts, breakdowns, and other emerging trends.

Sources

https://upstox.com/learning-center/share-market/a-comprehensive-guide-to-donchian-channels-formula-calculation-and-strategic-uses/ https://en.wikipedia.org/wiki/Donchian_channel

Output type: Dict["DCL": float, "DCM": float, "DCU": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 20

20

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

EMA dataclass

EMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close",
    smoothing: float = 2.0
)

Bases: Indicator[float | None]

Exponential Moving Average - EMA

The Exponential Moving Average is more responsive moving average compared to the Simple Moving Average (SMA). The weights are determined by alpha which is proportional to it's length.

Sources

https://www.investopedia.com/ask/answers/122314/what-exponential-moving-average-ema-formula-and-how-ema-calculated.asp

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
smoothing float

Smoothing multiplier for EMA. Defaults to 2.0

2.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Fisher dataclass

Fisher(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 9,
    signal_period: int = 1
)

Bases: Indicator[dict[str, float | None]]

Fisher Transform - FISHERT

Fisher Transform converts price position inside a rolling range into a Gaussian-like oscillator with a lagged signal line.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.fisher.html

Output type: Dict["FISHERT": float, "signal": float]

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

HL dataclass

HL(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 100
)

Bases: Indicator[dict[str, float | None]]

Highest Lowest - HL

Simple utility indicator to record and display the highest and lowest values N periods back.

Output type: Dict["low": float, "high": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 100

100

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

HLA dataclass

HLA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[float]

High Low Average - HLA

Output type: float

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

HLCA dataclass

HLCA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[float]

High Low Close Average - HLCA

Output type: float

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

HMA dataclass

HMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Hull Moving Average - HMA

It is a combination of weighted moving averages designed to be more responsive to current price fluctuations while still smoothing prices.

Sources

https://school.stockcharts.com/doku.php?id=technical_indicators:hull_moving_average

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Ichimoku dataclass

Ichimoku(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    tenkan: int = 9,
    kijun: int = 26,
    senkou: int = 52,
    include_chikou: bool = True,
    offset: int = 0
)

Bases: Indicator[dict[str, float | None]]

Ichimoku Kinko Hyo - ICHIMOKU

Ichimoku is a multi-line trend indicator composed of a conversion line, base line, two leading spans, and an optional chikou span.

This implementation is incremental and does not require future candle data. Shifted components are written to their target candle indexes as new candles arrive, so the chikou span updates older candle readings in place.

Output type: Dict["Lead_A": float, "Lead_B": float, "Conversion": float, "Base": float, "Span": float]

Parameters:

Name Type Description Default
tenkan int

Tenkan period. Defaults to 9

9
kijun int

Kijun period. Defaults to 26

26
senkou int

Senkou period. Defaults to 52

52
include_chikou bool

Include the chikou span. Defaults to True

True
offset int

Post shift. Defaults to 0

0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

JMA dataclass

JMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 7,
    source: Source = "close",
    phase: float = 0.0
)

Bases: Indicator[float | None]

Jurik Moving Average Average - JMA

The JMA is an adaptive moving average that aims to reduce lag and improve responsiveness to price changes compared to traditional moving averages. By incorporating volatility and phase shift components, the JMA seeks to provide traders with a more accurate and timely representation of market trends.

Sources

https://c.mql5.com/forextsd/forum/164/jurik_1.pdf

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 7

7
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
phase float

How heavy/light the average is [-100, 100]. Defaults to 0.0

0.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

KAMA dataclass

KAMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    fast: int = 2,
    slow: int = 30,
    source: Source = "close"
)

Bases: Indicator[float | None]

Kaufman's Adaptive Moving Average - KAMA

KAMA adapts its smoothing based on market efficiency. It responds faster in directional moves and slows down in noisy ranges.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.kama.html

Output type: float

Parameters:

Name Type Description Default
period int

Efficiency ratio lookback. Defaults to 10.

10
fast int

Fast EMA length. Defaults to 2.

2
slow int

Slow EMA length. Defaults to 30.

30
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

KC dataclass

KC(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 20,
    source: Source = "close",
    multiplier: float = 2.0,
    mamode: str = "ema",
    tr: bool = True
)

Bases: Indicator[dict[str, float | None]]

Keltner Channel - KC

Keltner channel is a technical analysis indicator showing a central moving average line plus channel lines at a distance above and below. A popular volatility indicator similar to Bollinger Bands and Donchian Channels.

Sources

https://www.investopedia.com/terms/k/keltnerchannel.asp

Output type: Dict["lower": float, "band": float, "upper": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 20

20
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
multiplier float

A positive float to multiply the bands. Defaults to 2.0

2.0
mamode str

Center line average type. One of "ema" or "sma". Defaults to "ema"

'ema'
tr bool

Use true range for the channel width. Defaults to True

True

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

KST dataclass

KST(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    roc1: int = 10,
    roc2: int = 15,
    roc3: int = 20,
    roc4: int = 30,
    sma1: int = 10,
    sma2: int = 10,
    sma3: int = 10,
    sma4: int = 15,
    signal_period: int = 9
)

Bases: Indicator[dict[str, float | None]]

Know Sure Thing - KST

KST combines four smoothed rate-of-change series into a weighted momentum oscillator with a signal line.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.kst.html

Output type: Dict["KST": float, "signal": float]

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

LinearRegression dataclass

LinearRegression(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Linear Regression - LR

Linear Regression fits a least-squares line over a rolling window and returns the line value using the same convention as pandas-ta linreg.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.linreg.html

Output type: float

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 14.

14
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

MACD dataclass

MACD(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    source: Source = "close",
    fast_period: int = 12,
    slow_period: int = 26,
    signal_period: int = 9
)

Bases: Indicator[dict[str, float | None]]

Moving Average Convergence Divergence - MACD

The MACD is a popular indicator to that is used to identify a security's trend. While APO and MACD are the same calculation, MACD also returns two more series called Signal and Histogram. The Signal is an EMA of MACD and the Histogram is the difference of MACD and Signal.

Sources

https://www.investopedia.com/ask/answers/122314/what-exponential-moving-average-ema-formula-and-how-ema-calculated.asp

Output type: Dict["MACD": float, "signal": float, "histogram": float]

Parameters:

Name Type Description Default
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
fast_period int

How many Periods to use for fast EMA. Defaults to 12

12
slow_period int

How many Periods to use for slow EMA. Defaults to 26

26
signal_period int

How many Periods to use for MACD signal. Defaults to 9

9

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

MFI dataclass

MFI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Money Flow Index - MFI

The money flow index (MFI) is an oscillator that ranges from 0 to 100. It is used to show the money flow over several days.

Sources

https://www.tradingview.com/wiki/Money_Flow_(MFI)

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

MOP dataclass

MOP(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 2,
    source: Source = "close"
)

Bases: Indicator[float | None]

Midpoint Over Period - MOP

A technical analysis tool that evaluates the average price movement by calculating the midpoint between the highest and lowest points over a specified period. This indicator aims to provide a smoother representation of price action, avoiding the choppiness of extreme highs and lows.

Sources

https://trendspider.com/learning-center/understanding-and-applying-the-midpoint-over-period-indicator-in-trading/

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 2

2
source str()

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

NATR dataclass

NATR(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14
)

Bases: Indicator[float | None]

Normalized Average True Range - NATR

NATR expresses ATR as a percentage of the current close, making volatility readings comparable across instruments with different price levels.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/volatility/help/pandas_ta.volatility.natr.html

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 14.

14

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

OBV dataclass

OBV(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[float]

On-Balance Volume - OBC

On-balance volume (OBV) is a technical analysis indicator intended to relate price and volume in the stock market. OBV is based on a cumulative total volume.

Sources

https://en.wikipedia.org/wiki/On-balance_volume

Output type: float

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

PivotPoints dataclass

PivotPoints(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[dict[str, float | None]]

Pivot Points - PP

Pivot point is a price level that is used by traders as a possible indicator of market movement. A pivot point is calculated as an average of significant prices (high, low, close) from the performance of a market in the prior trading period. If the market in the following period trades above the pivot point it is 1usually evaluated as a bullish sentiment, whereas trading below the pivot point is seen as bearish.

Sources

https://en.wikipedia.org/wiki/Pivot_point_(technical_analysis)

Output type: Dict["S1": float, "R1": float, "S2": float, "R2": float]

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RMA dataclass

RMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

wildeR's Moving Average - RMA

Wilder's Moving Average places more emphasis on recent price movements than other moving averages. This makes it a more responsive tool for short-term traders who need to adapt quickly to changing market conditions.

Sources

https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/WildersSmoothing https://www.incrediblecharts.com/indicators/wilder_moving_average.php

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

ROC dataclass

ROC(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Rate Of Change - ROC

The Price Rate of Change (ROC) indicator in trading refers to the percentage change between the current price and the price of a set number of periods ago. It is used to identify the momentum of price movement and help traders make informed decisions regarding buying or selling assets. This indicator is calculated by dividing the difference between the current price and the price of a set number of periods ago by the previous price and multiplying by 100.

Sources

https://en.wikipedia.org/wiki/Momentum_(technical_analysis)

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RSI dataclass

RSI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Relative Strength Index - RSI

The Relative Strength Index is popular momentum oscillator used to measure the velocity as well as the magnitude of directional price movements.

Sources

https://www.tradingview.com/support/solutions/43000502338-relative-strength-index-rsi/

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RVI dataclass

RVI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Relative Vigor Index - RVI

The Relative Vigor Index, or RVI, is a popular member of the “Oscillator” family of technical indicators. although the creator of the Relative Vigor Index is unknown, its design is very similar to Stochastics except that the closing price is compared with the Open rather than the Low price for the period.

Sources

https://www.thinkmarkets.com/en/learn-to-trade/indicators-and-patterns/indicators/relative-vigor-index-rvi-indicator/

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RegressionChannel dataclass

RegressionChannel(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close",
    std: float = 2.0
)

Bases: Indicator[dict[str, float | None]]

Regression Channel

Regression Channel fits a rolling least-squares line and places upper and lower bands around it using the residual standard deviation.

Output type: Dict["lower": float, "mid": float, "upper": float]

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 14.

14
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'
std float

Residual standard deviation multiplier. Defaults to 2.0.

2.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RegressionSlope dataclass

RegressionSlope(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Regression Slope - LRm

Regression Slope returns the least-squares slope over a rolling window.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.linreg.html

Output type: float

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 14.

14
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

SMA dataclass

SMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Simple Moving Average - SMA

The Simple Moving Average is the classic moving average that is the equally weighted average over n periods.

Sources

https://www.investopedia.com/terms/s/sma.asp

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

STDEV dataclass

STDEV(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 30,
    source: Source = "close"
)

Bases: Indicator[float | None]

Rolling Standard Deviation - STDEV

You use a rolling stdev when you expect the standard deviation to change over time. As long as the standard deviation is changing slowly enough, we should be able to see the change in the standard deviation over time if we use the right size window.

Sources

https://jonisalonen.com/2014/efficient-and-accurate-rolling-standard-deviation/

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 30

30
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

STDEVT dataclass

STDEVT(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close",
    multiplier: float = 2.0
)

Bases: Indicator[float | None]

Standard Deviation Threshold - STDEVT

Standard Deviation while calculating threshold returning boolean signal if change to input is higher than threshold

Sources

ChatGPT

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
multiplier float

A positive float to multiply the Deviation. Defaults to 2.0

2.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

STOCH dataclass

STOCH(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    slow_period: int = 3,
    smoothing_k: int = 3,
    source: Source = "close"
)

Bases: Indicator[dict[str, float | None]]

Stochastic - STOCH

The Stochastic Oscillator (STOCH) was developed by George Lane in the 1950's. He believed this indicator was a good way to measure momentum because changes in momentum precede changes in price.

It is a range-bound oscillator with two lines moving between 0 and 100. The first line (%K) displays the current close in relation to the period's high/low range. The second line (%D) is a Simple Moving Average of the %K line. The most common choices are a 14 period %K and a 3 period SMA for %D.

%K = SMA(100 * (Current Close - Lowest Low) / (Highest High - Lowest Low), smoothK) %D = SMA(%K, periodD)

Sources

https://www.tradingview.com/wiki/Stochastic_(STOCH)

Output type: Dict["stoch": float, "k": float, "d": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
slow_period int

How many Periods to use on smoothing d. Defaults to 3

3
smoothing_k int

How many Periods to use on smoothing K. Defaults to 3

3
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Squeeze dataclass

Squeeze(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    bb_length: int = 20,
    bb_std: float = 2.0,
    kc_length: int = 20,
    kc_scalar: float = 1.5,
    mom_length: int = 12,
    mom_smooth: int = 6,
    mamode: str = "sma",
    period: int | None = None
)

Bases: Indicator[dict[str, float | int | None]]

Squeeze

The TTM Squeeze is a volatility and momentum indicator. This implementation matches the default pandas_ta.squeeze output used by the source-of-truth fixture: Bollinger Bands versus SMA-based Keltner Channels plus mom(12) smoothed by sma(6).

Output type: Dict["SQZ": float, "ON": int, "OFF": int]

Parameters:

Name Type Description Default
bb_length int

Bollinger Bands period. Defaults to 20

20
bb_std float

Bollinger Bands standard deviation multiplier. Defaults to 2.0

2.0
kc_length int

Keltner Channel period. Defaults to 20

20
kc_scalar float

Keltner Channel scalar. Defaults to 1.5

1.5
mom_length int

Momentum period. Defaults to 12

12
mom_smooth int

Momentum smoothing period. Defaults to 6

6
mamode str

Momentum smoothing average type. One of "sma" or "ema"

'sma'
period int | None

Backwards-compatible alias for bb_length and kc_length

None

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

SqueezePro dataclass

SqueezePro(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    bb_length: int = 20,
    bb_std: float = 2.0,
    kc_length: int = 20,
    kc_scalar_wide: float = 2.0,
    kc_scalar_normal: float = 1.5,
    kc_scalar_narrow: float = 1.0,
    mom_length: int = 12,
    mom_smooth: int = 6,
    mamode: str = "sma"
)

Bases: Indicator[dict[str, float | int | None]]

SqueezePro

Squeeze Pro extends the classic squeeze by comparing Bollinger Bands against three Keltner Channel widths while keeping the same momentum oscillator.

Output type: Dict["SQZ": float, "Wide": int, "Normal": int, "Narrow": int, "OFF": int]

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Supertrend dataclass

Supertrend(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 7,
    source: Source = "close",
    multiplier: float = 3.0
)

Bases: Indicator[dict[str, float | int | None]]

Supertrend

It is used to identify market trends and potential entry and exit points in trading. The indicator is based on two dynamic values, period and multiplier, and incorporates the concept of Average True Range (ATR) to measure market volatility. The SuperTrend Indicator generates buy and sell signals by plotting a line on the price chart.

Output type: Dict["trend": float, "direction": int, "short": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 7

7
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
multiplier float

A positive float to multiply the ATR. Defaults to 3.0

3.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TEMA dataclass

TEMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Triple Exponential Moving Average - TEMA

TEMA reduces lag further than DEMA by combining three EMA layers into one smoothed output.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.tema.html

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 10.

10
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TR dataclass

TR(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[float | None]

True Range - TR

An method to expand a classical range (high minus low) to include possible gap scenarios.

Sources

https://www.macroption.com/true-range/

Output type: float

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TRIX dataclass

TRIX(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 30,
    signal_period: int = 9,
    scalar: float = 100.0,
    source: Source = "close"
)

Bases: Indicator[dict[str, float | None]]

Triple Exponential Average Oscillator - TRIX

TRIX measures the percent rate of change of a triple-smoothed EMA and pairs it with a simple moving average signal line.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.trix.html

Output type: Dict["TRIX": float, "signal": float]

Parameters:

Name Type Description Default
period int

EMA lookback. Defaults to 30.

30
signal_period int

Signal SMA lookback. Defaults to 9.

9
scalar float

Multiplier applied to the percent change. Defaults to 100.0.

100.0
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TSI dataclass

TSI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 25,
    smooth_period: int = 0,
    source: Source = "close"
)

Bases: Indicator[float | None]

True Strength Index - TSI TSI attempts to show both trend direction and overbought/oversold conditions, using moving averages of the underlying momentum of a financial instrument.

Sources

https://school.stockcharts.com/doku.php?id=technical_indicators:true_strength_index

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 25

25
smooth_period int

How much to smooth with EMA defaults: (period / 2) + (period % 2 > 0). Defaults to halve of period

0
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

UO dataclass

UO(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    fast: int = 7,
    medium: int = 14,
    slow: int = 28,
    fast_w: float = 4.0,
    medium_w: float = 2.0,
    slow_w: float = 1.0
)

Bases: Indicator[float | None]

Ultimate Oscillator - UO

The Ultimate Oscillator blends short, medium, and long buying pressure ratios to reduce false divergence signals from single-window oscillators.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.uo.html

Output type: float

Parameters:

Name Type Description Default
fast int

Fast lookback. Defaults to 7.

7
medium int

Medium lookback. Defaults to 14.

14
slow int

Slow lookback. Defaults to 28.

28
fast_w float

Fast period weight. Defaults to 4.0.

4.0
medium_w float

Medium period weight. Defaults to 2.0.

2.0
slow_w float

Slow period weight. Defaults to 1.0.

1.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

VWAP dataclass

VWAP(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    anchor: str | TimeFrame | timedelta | int | None = "D"
)

Bases: Indicator[float]

Volume-Weighted Average Price - VWAP

The volume-weighted average price is a technical analysis indicator used on intraday charts that resets at the start of every new trading session. Resets on the configured anchor timeframe (default: daily "D").

Sources

https://www.investopedia.com/terms/v/vwap.asp

Output type: float

Parameters:

Name Type Description Default
anchor Optional[str | TimeFrame | timedelta | int]

How to anchor VWAP, Depends on the index values, uses TimeFrame

'D'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

VWMA dataclass

VWMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10
)

Bases: Indicator[float | None]

Volume Weighted Moving Average - VWMA

VWMA is the ratio of the value of a security or financial asset traded to the total volume of transactions during a trading session. It is a measure of the average trading price for the period.

Sources

https://www.investopedia.com/ask/answers/071414/whats-difference-between-moving-average-and-weighted-moving-average.asp

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Vortex dataclass

Vortex(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    drift: int = 1
)

Bases: Indicator[dict[str, float | None]]

Vortex Indicator - VTX

Vortex compares directional movement against total true range to highlight bullish and bearish trend dominance.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/trend/help/pandas_ta.trend.vortex.html

Output type: Dict["VTXP": float, "VTXM": float]

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 14.

14
drift int

Previous candle offset for movement comparison. Defaults to 1.

1

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

WMA dataclass

WMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Weighted Moving Average - WMA

A Weighted Moving Average puts more weight on recent data and less on past data. This is done by multiplying each bar's price by a weighting factor. Because of its unique calculation, WMA will follow prices more closely than a corresponding Simple Moving Average.

Sources

https://www.investopedia.com/ask/answers/071414/whats-difference-between-moving-average-and-weighted-moving-average.asp

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

WillR dataclass

WillR(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

William's Percent R - WILLR

Williams %R is a momentum oscillator that measures the current close relative to the highest high and lowest low over a rolling lookback period.

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 14

14
source str

Which input field to compare against the rolling range. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

ZScore dataclass

ZScore(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 30,
    source: Source = "close",
    std: float = 1.0
)

Bases: Indicator[float | None]

Rolling Z Score - ZS

The rolling z-score measures how far the current value is from its rolling mean in units of rolling standard deviation. It is commonly used to detect statistical extremes and mean-reversion conditions.

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 30

30
source str

Which input field to calculate the indicator from. Defaults to "close"

'close'
std float

Standard deviation multiplier applied to the denominator. Defaults to 1.0

1.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)