Skip to content

rma

rma

Classes:

Name Description
RMA

wildeR's Moving Average - RMA

RMA dataclass

RMA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[TimeFramesSource] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

append

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

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.

purge

Remove this indicator value from all Candles

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,

readings

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

recalculate

Re-calculate this indicator value for all Candles

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_managed_indicator

add_managed_indicator(indicator: N) -> N

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, indicator: N) -> N:
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._mode = IndicatorMode.MANAGED

    if indicator.name == MANAGED_NAME:
        indicator.name = f"{self.name}_data"
    elif indicator._generated_name:
        indicator.name = f"{self.name}-{indicator.name}"

    indicator.candle_manager = self._candle_mngr
    indicator.rounding = None
    self.managed_indicators[indicator.name] = indicator
    return indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True) -> Indicator

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True) -> Indicator:
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._mode = IndicatorMode.SUB
    indicator._calc_prior = prior_calc

    if indicator._generated_name:
        indicator.name = f"{self.name}-{indicator.name}"

    indicator.candle_manager = self._candle_mngr
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator
    return self.sub_indicators[indicator.name]

append

append(candles: Candles)

append a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This wil 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.py
def append(self, candles: Candles):
    """append a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This wil 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.append(candles)
    self.calculate()

calculate

calculate()

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

Source code in hexital/core/indicator.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_sub_indicators(True, 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_sub_indicators(False, index)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = 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_sub_indicators(True, index)

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

        self._set_reading(reading, index)
        self._calculate_sub_indicators(False, 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.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.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()

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candle_mngr.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

reading

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

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator.py
def reading(
    self,
    source: Optional[Source] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> Reading | 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

reading_count

reading_count(
    source: Optional[Source] = None, index: Optional[int] = None
) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, source: Optional[Source] = None, index: Optional[int] = 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: Optional[Source] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, source: Optional[Source] = None, index: Optional[int] = 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,
    )

readings

readings(name: Optional[Source] = 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 Optional[str]

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.py
def readings(self, name: Optional[Source] = 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 (Optional[str]): 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_readings(name)

recalculate

recalculate()

Re-calculate this indicator value for all Candles

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