CRITICAL FIX: Use ?? instead of || for tp2SizePercent to allow 0 value
BUG FOUND: Line 558: tp2SizePercent: config.takeProfit2SizePercent || 100 When config.takeProfit2SizePercent = 0 (TP2-as-runner system), JavaScript's || operator treats 0 as falsy and falls back to 100, causing TP2 to close 100% of remaining position instead of activating trailing stop. IMPACT: - On-chain orders placed correctly (line 481 uses ?? correctly) - Position Manager reads from DB and expects TP2 to close position - Result: User sees TWO take-profit orders instead of runner system FIX: Changed both tp1SizePercent and tp2SizePercent to use ?? operator: - tp1SizePercent: config.takeProfit1SizePercent ?? 75 - tp2SizePercent: config.takeProfit2SizePercent ?? 0 This allows 0 value to be saved correctly for TP2-as-runner system. VERIFICATION NEEDED: Current open SHORT position in database has tp2SizePercent=100 from before this fix. Next trade will use correct runner system.
This commit is contained in:
@@ -140,16 +140,8 @@ export function scoreSignalQuality(params: {
|
||||
}
|
||||
|
||||
// Price position check (avoid chasing vs breakout detection)
|
||||
// CRITICAL: Low price position (< 40%) + weak trend (ADX < 25) = range-bound chop
|
||||
if (params.pricePosition > 0) {
|
||||
const isWeakTrend = params.adx > 0 && params.adx < 25
|
||||
const isLowInRange = params.pricePosition < 40
|
||||
|
||||
// ANTI-CHOP: Heavily penalize range-bound entries
|
||||
if (isLowInRange && isWeakTrend) {
|
||||
score -= 25
|
||||
reasons.push(`⚠️ RANGE-BOUND CHOP: Low position (${params.pricePosition.toFixed(0)}%) + weak trend (ADX ${params.adx.toFixed(1)}) = high whipsaw risk`)
|
||||
} else if (params.direction === 'long' && params.pricePosition > 95) {
|
||||
if (params.direction === 'long' && params.pricePosition > 95) {
|
||||
// High volume breakout at range top can be good
|
||||
if (params.volumeRatio > 1.4) {
|
||||
score += 5
|
||||
@@ -173,15 +165,13 @@ export function scoreSignalQuality(params: {
|
||||
}
|
||||
}
|
||||
|
||||
// Volume breakout bonus - ONLY if trend is strong enough (not choppy)
|
||||
// Removed old logic that conflicted with anti-chop filter
|
||||
// Old bonus was rewarding high volume even during choppy markets
|
||||
if (params.volumeRatio > 1.8 && params.atr < 0.6 && params.adx > 18) {
|
||||
// Volume breakout bonus (high volume can override other weaknesses)
|
||||
if (params.volumeRatio > 1.8 && params.atr < 0.6) {
|
||||
score += 10
|
||||
reasons.push(`Volume breakout compensates for low ATR (ADX ${params.adx.toFixed(1)} confirms trend)`)
|
||||
reasons.push(`Volume breakout compensates for low ATR`)
|
||||
}
|
||||
|
||||
const minScore = params.minScore || 65
|
||||
const minScore = params.minScore || 60
|
||||
const passed = score >= minScore
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user