"use client"; import React, { useState, useEffect } from "react"; import { ShieldCheck, ShieldAlert, TrendingUp, TrendingDown, Crosshair, Target, DollarSign, Percent, Zap, Layers, Award } from "lucide-react"; import { soundFX } from "@/lib/soundEffects"; interface TitanOrderTerminalProps { symbol: string; currentPrice: number; confluenceScore: number; confluenceDirection: string; accountEquity: number; onExecuteTrade: (trade: any) => Promise; externalSetup?: { lot: number; sl: number; tp: number; orderType: "BUY" | "SELL" } | null; } export const TitanOrderTerminal: React.FC = ({ symbol, currentPrice, confluenceScore, confluenceDirection, accountEquity, onExecuteTrade, externalSetup, }) => { const [orderType, setOrderType] = useState<"BUY" | "SELL">("BUY"); const [lot, setLot] = useState(0.01); const [entryPrice, setEntryPrice] = useState(currentPrice || 2735.40); const [slPrice, setSlPrice] = useState(2729.90); const [tp1Price, setTp1Price] = useState(2743.65); // 1:1.5 RR const [tp2Price, setTp2Price] = useState(2749.15); // 1:2.5 RR const [tp3Price, setTp3Price] = useState(2757.40); // 1:4.0 RR const [isSubmitting, setIsSubmitting] = useState(false); // Apply external setup from Agentic Copilot useEffect(() => { if (externalSetup) { setLot(externalSetup.lot); setSlPrice(externalSetup.sl); setTp2Price(externalSetup.tp); setOrderType(externalSetup.orderType); } }, [externalSetup]); // Sync entry and calculate default TP/SL whenever price changes useEffect(() => { if (currentPrice > 0) { setEntryPrice(currentPrice); if (orderType === "BUY") { const sl = Number((currentPrice - 5.50).toFixed(2)); setSlPrice(sl); const risk = currentPrice - sl; setTp1Price(Number((currentPrice + risk * 1.5).toFixed(2))); setTp2Price(Number((currentPrice + risk * 2.5).toFixed(2))); setTp3Price(Number((currentPrice + risk * 4.0).toFixed(2))); } else { const sl = Number((currentPrice + 5.50).toFixed(2)); setSlPrice(sl); const risk = sl - currentPrice; setTp1Price(Number((currentPrice - risk * 1.5).toFixed(2))); setTp2Price(Number((currentPrice - risk * 2.5).toFixed(2))); setTp3Price(Number((currentPrice - risk * 4.0).toFixed(2))); } } }, [currentPrice, orderType]); // Risk Math const slPips = Math.abs(entryPrice - slPrice) * 10.0; const riskDollars = (accountEquity * 0.01); // 1% of equity ($0.15 on $15.19) const isConfluenceQualified = confluenceScore >= 85; const handleOrderTypeSwitch = (type: "BUY" | "SELL") => { soundFX.playClick(); setOrderType(type); }; const handleExecute = async () => { soundFX.playClick(); setIsSubmitting(true); try { await onExecuteTrade({ symbol: symbol, order_type: orderType, lot: lot, price: entryPrice, sl: slPrice, tp: tp2Price, // Set primary TP to TP2 (1:2.5 RR) comment: `AuraTrade Titan ${orderType} ${confluenceScore}pts`, }); soundFX.playOrderExecuted(); } catch (e) { soundFX.playEmergency(); } finally { setIsSubmitting(false); } }; return (
{/* 1. Header & Confluence Speedometer */}

Ustad Sovereign Execution Desk

{/* Confluence Rating Pill */}
SMC: {confluenceScore}/100 {isConfluenceQualified ? "A+ READY" : "FILTERED"}
{/* 2. Buy / Sell Tab Switches */}
{/* 3. Parameter Inputs */}
{/* Entry & Lot Size */}
setEntryPrice(parseFloat(e.target.value) || 0)} className="w-full bg-[#0a1426] border border-[#182a47] rounded px-2.5 py-1.5 text-gray-100 font-bold focus:outline-none focus:border-cyan-500" />
USTAD PRESETS
setLot(parseFloat(e.target.value) || 0.01)} className="w-full bg-[#0a1426] border border-[#182a47] rounded px-2.5 py-1.5 text-gray-100 font-bold focus:outline-none focus:border-cyan-500" />
{/* Hard Stop Loss */}
MANDATORY HARD SL ($) -${riskDollars.toFixed(2)} (1.0% Cap)
setSlPrice(parseFloat(e.target.value) || 0)} className="w-full bg-[#050914] border border-red-900/40 rounded px-2.5 py-1.5 text-rose-300 font-bold focus:outline-none focus:border-rose-500" />
Distance: {slPips.toFixed(0)} pips Broker-side guaranteed execution
{/* Multi-Tier Profit Targets (TP1, TP2, TP3) */}
MULTI-TIER PROFIT TARGETS Scaling Strategy
{/* TP1 */}
TP1 (1:1.5)
${tp1Price.toFixed(2)}
Take 50%
{/* TP2 */}
TP2 (1:2.5)
${tp2Price.toFixed(2)}
Move BE
{/* TP3 */}
TP3 (1:4.0)
${tp3Price.toFixed(2)}
Full Runner
{/* 4. Institutional 1-Click Execution Button */}
Exness Server 15 Sub-second Gateway • Zero Mock Data
); };