Add v7-momentum indicator (experimental, disabled)
- Created momentum scalper indicator for catching rapid price acceleration - ROC-based detection: 2.0% threshold over 5 bars - Volume confirmation: 2.0x spike (checks last 3 bars) - ADX filter: Requires 12+ minimum directional movement - Anti-chop filter: Blocks signals in dead markets - Debug table: Real-time metric display for troubleshooting Status: Functional but signal quality inferior to v6 HalfTrend Decision: Shelved for now, continue with proven v6 strategy File: docs/guides/MOMENTUM_INDICATOR_V1.pine (239 lines) Lessons learned: - Momentum indicators inherently noisy (40-50% WR expected) - Signals either too early (false breakouts) or too late (miss move) - Volume spike timing issue: Often lags price move by 1-2 bars - Better to optimize proven strategy than add complexity Related: Position Manager duplicate update bug fixed (awaiting verification)
This commit is contained in:
@@ -488,8 +488,24 @@ export class PositionManager {
|
||||
// else: small profit/loss near breakeven, default to SL (could be manual close)
|
||||
}
|
||||
|
||||
// Update database
|
||||
// Update database - CRITICAL: Only update once per trade!
|
||||
const holdTimeSeconds = Math.floor((Date.now() - trade.entryTime) / 1000)
|
||||
|
||||
// CRITICAL BUG FIX: Mark trade as processed IMMEDIATELY to prevent duplicate updates
|
||||
// Remove from monitoring BEFORE database update to prevent race condition
|
||||
const tradeId = trade.id
|
||||
|
||||
// VERIFICATION: Check if already removed (would indicate duplicate processing attempt)
|
||||
if (!this.activeTrades.has(tradeId)) {
|
||||
console.log(`⚠️ DUPLICATE PROCESSING PREVENTED: Trade ${tradeId} already removed from monitoring`)
|
||||
console.log(` This is the bug fix working - without it, we'd update DB again with compounded P&L`)
|
||||
return // Already processed, don't update DB again
|
||||
}
|
||||
|
||||
this.activeTrades.delete(tradeId)
|
||||
console.log(`🗑️ Removed trade ${tradeId} from monitoring (BEFORE DB update to prevent duplicates)`)
|
||||
console.log(` Active trades remaining: ${this.activeTrades.size}`)
|
||||
|
||||
try {
|
||||
await updateTradeExit({
|
||||
positionId: trade.positionId,
|
||||
@@ -510,8 +526,11 @@ export class PositionManager {
|
||||
console.error('❌ Failed to save external closure:', dbError)
|
||||
}
|
||||
|
||||
// Remove from monitoring
|
||||
await this.removeTrade(trade.id)
|
||||
// Stop monitoring if no more trades
|
||||
if (this.activeTrades.size === 0 && this.isMonitoring) {
|
||||
this.stopMonitoring()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user