Skip to content

Custom Indicators

Indicators in Quantum Trader are implemented in the backend and exposed via API.

backend/app/services/
├── indicators/
│ ├── __init__.py
│ ├── base.py # Base indicator class
│ ├── moving_avg.py # SMA, EMA
│ ├── momentum.py # RSI, MACD
│ └── volatility.py # ATR, Bollinger
backend/app/services/indicators/custom.py
from .base import Indicator
import pandas as pd
class MyIndicator(Indicator):
"""Custom indicator implementation."""
def __init__(self, period: int = 14):
self.period = period
def calculate(self, df: pd.DataFrame) -> pd.Series:
"""Calculate indicator values."""
# Your calculation logic here
return df['close'].rolling(self.period).mean()
backend/app/services/indicators/__init__.py
from .custom import MyIndicator
INDICATORS = {
# ... existing indicators
'MY_INDICATOR': MyIndicator,
}

If you want a dedicated endpoint:

backend/app/api/v1/indicators.py
@router.get("/my-indicator")
async def get_my_indicator(
symbol: str,
period: int = 14
):
# Implementation
frontend/src/hooks/useIndicators.ts
export const AVAILABLE_INDICATORS = [
// ... existing
{ id: 'MY_INDICATOR', name: 'My Indicator', params: ['period'] },
];
frontend/src/components/Chart/indicators.ts
export function renderMyIndicator(data: number[], options: IndicatorOptions) {
// Rendering logic for Lightweight Charts
}