Add timeframe-aware signal quality scoring for 5min charts

- Lower ADX/ATR thresholds for 5min timeframe (ADX 12-22, ATR 0.2-0.7%)
- Add anti-chop filter: -20 points for extreme sideways (ADX<10, ATR<0.25, Vol<0.9)
- Pass timeframe parameter through check-risk and execute endpoints
- Fixes flip-flop losses from overly strict 5min filters
- Higher timeframes unchanged (still use ADX 18+, ATR 0.4+)

5min scoring now:
- ADX 12-15: moderate trend (+5)
- ADX 22+: strong trend (+15)
- ATR 0.2-0.35: acceptable (+5)
- ATR 0.35+: healthy (+10)
- Extreme chop penalty prevents whipsaw trades
This commit is contained in:
mindesbunister
2025-11-07 08:56:19 +01:00
parent b52a980138
commit 0365560c5b
3 changed files with 76 additions and 24 deletions

View File

@@ -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', '15', '60', '1D'
// Optional context metrics from TradingView
atr?: number
adx?: number
@@ -57,6 +58,7 @@ function shouldAllowScaling(
pricePosition: newSignal.pricePosition,
direction: newSignal.direction,
minScore: config.minScaleQualityScore,
timeframe: newSignal.timeframe,
})
// 2. Check quality score (higher bar than initial entry)
@@ -271,7 +273,8 @@ export async function POST(request: NextRequest): Promise<NextResponse<RiskCheck
volumeRatio: body.volumeRatio || 0,
pricePosition: body.pricePosition || 0,
direction: body.direction,
minScore: 60 // Hardcoded threshold
minScore: 60, // Hardcoded threshold
timeframe: body.timeframe,
})
if (!qualityScore.passed) {