Custom Indicators
Indicator Architecture
Section titled “Indicator Architecture”Indicators in Quantum Trader are implemented in the backend and exposed via API.
Backend Structure
Section titled “Backend Structure”backend/app/services/├── indicators/│ ├── __init__.py│ ├── base.py # Base indicator class│ ├── moving_avg.py # SMA, EMA│ ├── momentum.py # RSI, MACD│ └── volatility.py # ATR, BollingerCreating a New Indicator
Section titled “Creating a New Indicator”1. Implement the Calculation
Section titled “1. Implement the Calculation”from .base import Indicatorimport 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()2. Register the Indicator
Section titled “2. Register the Indicator”from .custom import MyIndicator
INDICATORS = { # ... existing indicators 'MY_INDICATOR': MyIndicator,}3. Add API Endpoint (Optional)
Section titled “3. Add API Endpoint (Optional)”If you want a dedicated endpoint:
@router.get("/my-indicator")async def get_my_indicator( symbol: str, period: int = 14): # ImplementationFrontend Integration
Section titled “Frontend Integration”Add to Chart
Section titled “Add to Chart”export const AVAILABLE_INDICATORS = [ // ... existing { id: 'MY_INDICATOR', name: 'My Indicator', params: ['period'] },];Render Indicator
Section titled “Render Indicator”export function renderMyIndicator(data: number[], options: IndicatorOptions) { // Rendering logic for Lightweight Charts}Next Steps
Section titled “Next Steps”- Code-Based Strategies - Use custom indicators
- API Reference - Expose via API