diff --git a/workflows/trading/moneyline_v11_2_strategy.pinescript b/workflows/trading/moneyline_v11_2_strategy.pinescript index 88677b1..921830a 100644 --- a/workflows/trading/moneyline_v11_2_strategy.pinescript +++ b/workflows/trading/moneyline_v11_2_strategy.pinescript @@ -1,7 +1,13 @@ //@version=6 -strategy("Money Line v11.2 STRATEGY", shorttitle="ML v11.2 Strat", overlay=true, pyramiding=0, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100) -// V11.2 STRATEGY VERSION (Dec 25, 2025): -// Same logic as indicator but with entries/exits for TradingView Strategy Report +strategy("Money Line v11.2 STRATEGY", shorttitle="ML v11.2 Strat", overlay=true, pyramiding=0, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, close_entries_rule="ANY") +// V11.2 STRATEGY VERSION (Jan 2, 2026): +// FIXED: Now tests LONG and SHORT as independent trades (not reversals) +// - Opposite signal CLOSES current position, then opens NEW position +// - This matches how live webhook trading actually works +// - Backtest results now accurately reflect real trading performance + +// === DIRECTION MODE === +directionMode = input.string("Both", "Trade Direction", options=["Both", "Long Only", "Short Only"], group="Direction") // === CORE PARAMETERS === atrPeriod = input.int(12, "ATR Period", minval=1, group="Core") @@ -154,16 +160,31 @@ finalLongSignal = buyReady and adxOk and longBufferOk and rsiLongOk and longPosi finalShortSignal = sellReady and adxOk and shortBufferOk and rsiShortOk and shortPositionOk and volumeOk // ============================================================================= -// STRATEGY ENTRIES & EXITS +// STRATEGY ENTRIES & EXITS (FIXED: Independent Long/Short tracking) // ============================================================================= -if finalLongSignal +// Determine if direction is allowed +allowLong = directionMode == "Both" or directionMode == "Long Only" +allowShort = directionMode == "Both" or directionMode == "Short Only" + +// Track positions +isLong = strategy.position_size > 0 +isShort = strategy.position_size < 0 +isFlat = strategy.position_size == 0 + +// === LONG ENTRY === +if finalLongSignal and allowLong + if isShort + strategy.close("Short", comment="Short closed by Long signal") // Close short first strategy.entry("Long", strategy.long) -if finalShortSignal +// === SHORT ENTRY === +if finalShortSignal and allowShort + if isLong + strategy.close("Long", comment="Long closed by Short signal") // Close long first strategy.entry("Short", strategy.short) -// Exits with TP/SL +// === Exits with TP/SL === if strategy.position_size > 0 strategy.exit("L Exit", "Long", stop=strategy.position_avg_price * (1 - slPct/100), limit=strategy.position_avg_price * (1 + tpPct/100)) if strategy.position_size < 0