Indicators Module

Compose indicators from strategies via use_indicator() and the indicators.* namespace.

indicators

indicators.name(**params)

Call any indicator from your indicators/ folder inside a strategy.

The indicators namespace lets you call any indicator you have created in your indicators/ folder. Access them by name using indicators.name(), passing any parameters as keyword arguments. The indicator is automatically plotted on the chart and the computed Series is returned for use in signal logic.

Parameters

  • name (str, default required): The indicator filename (without .py). For example, indicators/sma.py becomes indicators.sma()
  • **params (any, default indicator defaults): Override any input parameters defined in the indicator

Returns

pandas Series with the indicator values

Example

@strategy(name="MA Crossover", overlay=True)
class MACrossover:
    fast = input.int(10, "Fast Period")
    slow = input.int(20, "Slow Period")

    def calculate(self, df):
        fast_ma = indicators.sma(period=self.fast, color="#26A69A")
        slow_ma = indicators.sma(period=self.slow, color="#EF5350")

        return {
            'entry_long': cross_above(fast_ma, slow_ma),
            'exit_long': cross_below(fast_ma, slow_ma),
        }

Notes

  • Indicators are discovered from your workspace indicators/ folder.
  • Any @indicator-decorated script becomes callable through this namespace.
  • Results are cached per (name, params) combination for performance.

use_indicator

use_indicator(name, **params)

Alternative function syntax for calling indicators by name.

Loads and executes an indicator from your indicators/ folder by name. Functionally equivalent to indicators.name() but uses a function call instead of attribute access. Useful when the indicator name is stored in a variable.

Parameters

  • name (str, default required): Indicator filename without .py
  • **params (any, default indicator defaults): Override any input parameters

Returns

pandas Series with the indicator values

Example

from quant_charts import use_indicator

sma = use_indicator('sma', period=20)
rsi = use_indicator('rsi', period=14)

Notes

  • Equivalent to the indicators.name() namespace syntax.