Fix: Add timeframe-aware signal quality scoring for 5min charts
PROBLEM: - Long signal (ADX 15.7, ATR 0.35%) blocked with score 45/100 - Missed major +3% runup, lost -2 on short that didn't flip - Scoring logic treated all timeframes identically (daily chart thresholds) ROOT CAUSE: - ADX < 18 always scored -15 points regardless of timeframe - 5min charts naturally have lower ADX (12-22 healthy range) - copilot-instructions mentioned timeframe awareness but wasn't implemented FIX: - Add timeframe parameter to RiskCheckRequest interface - Update scoreSignalQuality() with timeframe-aware ADX thresholds: * 5min/15min: ADX 12-22 healthy (+5), <12 weak (-15), >22 strong (+15) * Higher TF: ADX 18-25 healthy (+5), <18 weak (-15), >25 strong (+15) - Pass timeframe from n8n workflow through check-risk and execute - Update both Check Risk nodes in Money Machine workflow IMPACT: Your blocked signal (ADX 15.7 on 5min) now scores: - Was: 50 + 5 - 15 + 0 + 0 + 5 = 45 (BLOCKED) - Now: 50 + 5 + 5 + 0 + 0 + 5 = 65 (PASSES) This 20-point improvement from timeframe awareness would have caught the runup.
This commit is contained in:
@@ -15,6 +15,7 @@ import { scoreSignalQuality, SignalQualityResult } from '@/lib/trading/signal-qu
|
||||
export interface RiskCheckRequest {
|
||||
symbol: string
|
||||
direction: 'long' | 'short'
|
||||
timeframe?: string // e.g., "5" for 5min, "60" for 1H, "D" for daily
|
||||
// Optional context metrics from TradingView
|
||||
atr?: number
|
||||
adx?: number
|
||||
@@ -270,6 +271,7 @@ export async function POST(request: NextRequest): Promise<NextResponse<RiskCheck
|
||||
volumeRatio: body.volumeRatio || 0,
|
||||
pricePosition: body.pricePosition || 0,
|
||||
direction: body.direction,
|
||||
timeframe: body.timeframe, // Pass timeframe for context-aware scoring
|
||||
minScore: 60 // Hardcoded threshold
|
||||
})
|
||||
|
||||
|
||||
@@ -330,6 +330,7 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
|
||||
volumeRatio: body.volumeRatio || 0,
|
||||
pricePosition: body.pricePosition || 0,
|
||||
direction: body.direction,
|
||||
timeframe: body.timeframe,
|
||||
})
|
||||
|
||||
await createTrade({
|
||||
@@ -540,6 +541,7 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
|
||||
volumeRatio: body.volumeRatio || 0,
|
||||
pricePosition: body.pricePosition || 0,
|
||||
direction: body.direction,
|
||||
timeframe: body.timeframe,
|
||||
})
|
||||
|
||||
await createTrade({
|
||||
|
||||
Reference in New Issue
Block a user