import { useEffect, useState } from 'react'; import { Settings, Zap, BookOpen, Grid3X3, Check } from 'lucide-react'; import axios from 'axios'; interface Indicator { id: string; name: string; periods?: number[]; default_period?: number; description?: string; type: string; } interface IndicatorCategory { name: string; description: string; indicators: Indicator[]; } interface Preset { id: string; name: string; indicators: string[]; description: string; } export default function AdvancedIndicatorsPanel() { const [categories, setCategories] = useState>({}); const [presets, setPresets] = useState([]); const [selectedIndicators, setSelectedIndicators] = useState>(new Set()); const [activeTab, setActiveTab] = useState<'presets' | 'custom' | 'guide'>('presets'); const [loading, setLoading] = useState(true); const [selectedPreset, setSelectedPreset] = useState(null); const [cheatSheet, setCheatSheet] = useState(null); // Fetch indicators and presets useEffect(() => { const fetchData = async () => { try { setLoading(true); // Fetch available indicators const indicatorsResponse = await axios.get('/api/indicators/available'); setCategories(indicatorsResponse.data.categories || {}); // Fetch presets const presetsResponse = await axios.get('/api/indicators/presets'); setPresets(presetsResponse.data.presets || []); // Fetch cheat sheet const cheatSheetResponse = await axios.get('/api/indicators/cheat-sheet'); setCheatSheet(cheatSheetResponse.data || {}); } catch (error) { console.error('Error fetching indicators data:', error); } finally { setLoading(false); } }; fetchData(); }, []); const handleIndicatorToggle = (indicatorId: string) => { const newSet = new Set(selectedIndicators); if (newSet.has(indicatorId)) { newSet.delete(indicatorId); } else { newSet.add(indicatorId); } setSelectedIndicators(newSet); }; const handlePresetSelect = (presetId: string) => { const preset = presets.find((p) => p.id === presetId); if (preset) { setSelectedIndicators(new Set(preset.indicators)); setSelectedPreset(presetId); } }; const getTypeColor = (type: string): string => { switch (type) { case 'trend': return 'bg-blue-900 text-blue-300'; case 'momentum': return 'bg-purple-900 text-purple-300'; case 'volatility': return 'bg-orange-900 text-orange-300'; case 'level': return 'bg-green-900 text-green-300'; case 'volume': return 'bg-pink-900 text-pink-300'; default: return 'bg-gray-700 text-gray-300'; } }; if (loading) { return (

Advanced Indicators

Loading indicators...
); } return (

Advanced Technical Indicators

{/* Tabs */}
{/* Presets Tab */} {activeTab === 'presets' && (
{presets.map((preset) => (
handlePresetSelect(preset.id)} className={`p-4 rounded-lg border cursor-pointer transition ${ selectedPreset === preset.id ? 'bg-blue-900 border-blue-500' : 'bg-dark-bg border-dark-border hover:border-blue-500' }`} >

{preset.name} {selectedPreset === preset.id && }

{preset.description}

{preset.indicators.length} indicators
{preset.indicators.map((ind) => ( {ind} ))}
))}
)} {/* Custom Setup Tab */} {activeTab === 'custom' && (
{Object.entries(categories).map(([categoryKey, category]) => (

{category.name}

{category.description}

{category.indicators.map((indicator) => ( ))}
))} {selectedIndicators.size > 0 && (

Configuration Ready

You've selected {selectedIndicators.size} indicator(s). Click below to apply.

)}
)} {/* Quick Guide Tab */} {activeTab === 'guide' && cheatSheet && (
{Object.entries(cheatSheet).map(([key, value]) => (

{key.replace(/_/g, ' ')}

{typeof value === 'object' && !Array.isArray(value) && Object.entries(value).map(([subKey, subValue]) => (

{subKey}

{String(subValue)}

))}
))}
)}
{/* Selected Indicators Summary */} {selectedIndicators.size > 0 && activeTab !== 'guide' && (

Currently Selected

{Array.from(selectedIndicators).map((ind) => (
{ind}
))}
)} {/* Indicator Types Legend */}

Indicator Types

Trend
Momentum
Volatility
Support/Resistance
Volume
{/* Best Practices */}

Pro Tips

  • ✓ Use 2-3 indicators maximum to avoid signal conflicts
  • ✓ Combine different indicator types (trend + momentum + volatility)
  • ✓ Scalping: Use fast periods (5, 10, 14)
  • ✓ Swing/Position: Use standard periods (20, 50, 200)
  • ✓ Always confirm signals with price action and volume
  • ✓ Use presets as a starting point, customize based on your style
); }