一键导入
custom-indicator
// Create a custom technical indicator using Numba JIT + NumPy. Generates production-grade, O(n) optimized indicator functions with charting and benchmarking.
// Create a custom technical indicator using Numba JIT + NumPy. Generates production-grade, O(n) optimized indicator functions with charting and benchmarking.
OpenAlgo indicator expert. Use when user asks about technical indicators, charting, plotting indicators, creating custom indicators, building dashboards, real-time feeds, scanning stocks, indicator combinations, or using openalgo.ta. Also triggers for indicator functions (sma, ema, rsi, macd, supertrend, bollinger, atr, adx, ichimoku, stochastic, obv, vwap, crossover, crossunder, exrem).
Build a web dashboard for technical indicator analysis using Plotly Dash or Streamlit. Supports single-symbol, multi-symbol, and multi-timeframe layouts with real-time refresh.
Set up the Python environment for OpenAlgo indicator analysis. Installs openalgo, plotly, dash, streamlit, numba, yfinance, matplotlib, seaborn, and creates the project folder structure.
Chart any technical indicator on a symbol using Plotly. Creates interactive dark-themed charts with candlestick, overlays, and subplots. Supports all 100+ openalgo.ta indicators.
Scan multiple symbols with indicator conditions. Find stocks matching RSI oversold, EMA crossovers, Supertrend signals, and custom filter combinations.
Set up real-time indicator computation on live WebSocket market data. Streams LTP/Quote/Depth and computes indicators in real-time with optional Plotly live charting.
| name | custom-indicator |
| description | Create a custom technical indicator using Numba JIT + NumPy. Generates production-grade, O(n) optimized indicator functions with charting and benchmarking. |
| argument-hint | [indicator-name] |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
Create a custom technical indicator with Numba JIT compilation for production-grade speed.
$0 = indicator name (e.g., zscore, squeeze, vwap-bands, custom-rsi, mean-reversion). Required.If no arguments, ask the user what indicator they want to build.
rules/custom-indicators.md — Numba patterns and templatesrules/numba-optimization.md — Performance best practicesrules/indicator-catalog.md — Check if indicator already exists in openalgo.taopenalgo.ta, tell the user and show the existing APIcustom_indicators/{indicator_name}/ directory (on-demand){indicator_name}.py with:"""
{Indicator Name} — Custom Indicator
Description: {what it measures}
Category: {trend/momentum/volatility/volume/oscillator}
"""
import numpy as np
from numba import njit
import pandas as pd
# --- Core Computation (Numba JIT) ---
@njit(cache=True, nogil=True)
def _compute_{name}(data: np.ndarray, period: int) -> np.ndarray:
"""Numba-compiled core computation."""
n = len(data)
result = np.full(n, np.nan)
# ... O(n) algorithm ...
return result
# --- Public API ---
def {name}(data, period=20):
"""
{Indicator Name}
Args:
data: Close prices (numpy array, pandas Series, or list)
period: Lookback period (default: 20)
Returns:
Same type as input with indicator values
"""
if isinstance(data, pd.Series):
idx = data.index
result = _compute_{name}(data.values.astype(np.float64), period)
return pd.Series(result, index=idx, name="{Name}({period})")
arr = np.asarray(data, dtype=np.float64)
return _compute_{name}(arr, period)
chart.py for visualization:"""Chart the custom indicator with Plotly."""
import os
from pathlib import Path
from datetime import datetime, timedelta
from dotenv import find_dotenv, load_dotenv
from openalgo import api, ta
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from {indicator_name} import {name}
# ... fetch data, compute indicator, create chart ...
benchmark.py for performance testing:"""Benchmark the custom indicator."""
import numpy as np
import time
from {indicator_name} import {name}
# Warmup
data = np.random.randn(1000)
_ = {name}(data, 20)
# Benchmark on different sizes
for size in [10_000, 100_000, 500_000]:
data = np.random.randn(size)
t0 = time.perf_counter()
_ = {name}(data, 20)
elapsed = (time.perf_counter() - t0) * 1000
print(f"{size:>10,} bars: {elapsed:>8.2f}ms")
@njit(cache=True, nogil=True) on all compute functionsnp.full(n, np.nan) to initialize output arraysnp.isnan() for NaN checksfor loops (Numba compiles to machine code)fastmath=True (breaks np.isnan())@njit@njit@njitThese existing functions can be called inside @njit:
from openalgo.indicators.utils import (
sma, ema, ema_wilder, stdev, true_range, atr_wilder,
highest, lowest, rolling_sum, crossover, crossunder
)
| Pattern | Implementation |
|---|---|
| Z-Score | (value - rolling_mean) / rolling_stdev |
| Squeeze | Bollinger inside Keltner channel |
| VWAP Bands | VWAP + N * rolling stdev of (close - vwap) |
| Momentum Score | Weighted sum of RSI + MACD + ADX conditions |
| Mean Reversion | Distance from SMA as % + threshold |
| Range Filter | ATR-based dynamic filter on close |
| Trend Strength | ADX + directional movement composite |
/custom-indicator zscore
/custom-indicator squeeze-momentum
/custom-indicator vwap-bands
/custom-indicator range-filter