How to Register Custom Technical Indicators in the OpenBB Technical Analysis Extension

To register custom technical indicators in OpenBB, subclass PltTA from the Plotly-TA framework, decorate your plotting method with @indicator(), and import the class in the technical extension's __init__.py to auto-register it with both the Python SDK and REST API.

The OpenBB technical analysis extension utilizes the Plotly-TA framework to render financial charts. By leveraging the extension's plugin architecture, developers can register custom technical indicators that automatically surface as callable endpoints under the obb.technical namespace and the /api/v1/technical route.

Architecture Overview

OpenBB's technical extension relies on the PltTA base class located in openbb_platform/obbject_extensions/charting/openbb_charting/core/plotly_ta/base.py. This class provides the foundation for all technical indicators, handling parameter parsing and figure generation through Plotly.

The registration mechanism scans for subclasses of PltTA that are imported within the extension's package scope. When the extension loader discovers these classes, it automatically generates the corresponding Python SDK methods and REST API endpoints according to the patterns defined in technical_views.py.

Step 1: Create the Indicator File

Place your custom indicator implementation in the technical extension's custom directory to maintain separation from core code.

Create a new Python file at openbb_platform/extensions/technical/openbb_technical/custom/my_indicator.py. This location follows the convention established in custom_indicators_plugin.py, which serves as the reference template for indicator implementation.

Step 2: Subclass PltTA and Implement Logic

Implement your indicator by inheriting from PltTA and defining a plotting method decorated with @indicator(). This decorator signals the framework to register the method as a callable technical indicator.


# openbb_platform/extensions/technical/openbb_technical/custom/my_indicator.py

"""Custom technical indicator – Simple Moving Average (SMA) example."""

import pandas as pd
from openbb_charting.core.openbb_figure import OpenBBFigure
from openbb_charting.core.plotly_ta.base import PltTA, indicator


class MySMA(PltTA):
    """Simple Moving Average indicator implementation."""

    @indicator()
    def plot_my_sma(self, fig: OpenBBFigure, df_ta: pd.DataFrame):
        """Add a custom SMA line to the figure."""
        # Retrieve parameter values from the indicator configuration

        window = self.params["my_sma"].get_argument_values("window") or 20
        
        # Calculate the technical indicator values

        df_ta["my_sma"] = df_ta["close"].rolling(window=int(window)).mean()

        # Render the indicator on the primary chart area

        fig.add_scatter(
            x=df_ta.index,
            y=df_ta["my_sma"],
            mode="lines",
            name=f"SMA({window})",
            line=dict(width=2, dash="dot"),
            row=1,
            col=1,
            secondary_y=False,
            showlegend=True,
        )
        return fig

The OpenBBFigure object provides the plotting interface, while df_ta contains the OHLCV data as a Pandas DataFrame. Access indicator parameters through self.params["indicator_name"], which returns an object exposing get_argument_values() for retrieving user-specified inputs like window lengths or thresholds.

Step 3: Register the Indicator Class

Import your subclass in the technical extension's package initializer to trigger registration during extension loading.

Modify openbb_platform/extensions/technical/openbb_technical/__init__.py to include your indicator class:


# openbb_platform/extensions/technical/openbb_technical/__init__.py

"""Technical analysis extension package."""

# Existing imports

from .technical_views import *      # noqa: F401,F403

# Register custom indicators

from .custom.my_indicator import MySMA   # noqa: F401

The extension loader automatically discovers any imported PltTA subclasses and exposes them through the view generation logic in technical_views.py. No manual endpoint registration is required.

Step 4: Access Through SDK and API

Once imported, your custom indicator becomes immediately available via both interfaces.

Python SDK Usage:

from openbb import obb

# Fetch historical price data

df = obb.stocks.equity.price_historical("AAPL", start_date="2024-01-01")

# Call the custom indicator using the method name defined in the class

fig = obb.technical.my_sma(df=df, window=30)
fig.show()

REST API Endpoint:


GET /api/v1/technical/my_sma?symbol=AAPL&window=30

The endpoint name derives directly from the method name following the @indicator() decorator. Parameters defined in your implementation become query parameters in the REST interface and keyword arguments in the Python SDK.

Summary

  • Inherit from PltTA in openbb_charting/core/plotly_ta/base.py to create compliant indicator classes
  • Apply @indicator() decorator to methods that should be exposed as technical indicators
  • Place custom files in openbb_platform/extensions/technical/openbb_technical/custom/ to maintain modularity
  • Import subclasses in __init__.py to trigger automatic registration with the extension loader
  • Access instantly via obb.technical.<indicator_name> in Python or /api/v1/technical/<indicator_name> via HTTP

Frequently Asked Questions

Where should I place custom indicator files in the OpenBB codebase?

Place custom indicators in openbb_platform/extensions/technical/openbb_technical/custom/ or any subdirectory within the technical extension package. The framework discovers indicators through Python imports rather than file system scanning, so the specific filename matters less than ensuring the class is imported in the extension's __init__.py.

What base class must I use to create a custom technical indicator?

You must inherit from PltTA (Plotly Technical Analysis), which is defined in openbb_platform/obbject_extensions/charting/openbb_charting/core/plotly_ta/base.py. This base class provides the parameter handling, figure management, and serialization logic required for integration with OpenBB's charting system.

How does the @indicator() decorator function in OpenBB?

The @indicator() decorator registers the decorated method with the Plotly-TA plugin system. It captures metadata about the indicator's name, parameters, and return type, enabling the extension loader to generate the corresponding view functions in technical_views.py and REST API routes without manual configuration.

Can custom indicators accept user-defined parameters like window periods?

Yes. Access user inputs through self.params["indicator_name"].get_argument_values("parameter_name") within your plotting method. These parameters automatically map to function arguments in the Python SDK and query parameters in the REST API, following the pattern used in built-in indicators like SMA or RSI.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →