Skip to content
TheChatArchiveThe Chat Archive
Kimikimi-k2-0711-previewHugging Face Arena Expert 5K

Error at 280:56 Syntax error at input 'end of line without line…

  1. User

    Error at 280:56 Syntax error at input 'end of line without line continuation'://@version=5 strategy("Enhanced True IPDA Strategy v4", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=1, commission_type=strategy.commission.percent, commission_value=0.01, pyramiding=0, max_bars_back=500)

    // ======================================== // INPUT PARAMETERS // ======================================== // IPDA Core Settings rangePeriod = input.int(20, "Range Period for Premium/Discount", minval=20, group="IPDA Core") equilibriumBand = input.float(0.1, "Equilibrium Band Width", minval=0.05, maxval=0.2, step=0.01, group="IPDA Core") premiumLevel = input.float(0.7, "Premium Level (0.7 = 70%)", minval=0.6, maxval=0.9, group="IPDA Core") discountLevel = input.float(0.3, "Discount Level (0.3 = 30%)", minval=0.1, maxval=0.4, group="IPDA Core")

    // Order Block Settings obLookback = input.int(10, "Order Block Lookback", minval=5, maxval=20, group="Order Blocks") obVolumeMultiplier = input.float(1.5, "OB Volume Multiplier", minval=1.0, step=0.1, group="Order Blocks") requireOBMitigation = input.bool(true, "Require OB Mitigation", group="Order Blocks")

    // Market Structure Settings swingPeriod = input.int(10, "Swing Point Period", minval=3, group="Market Structure") bosThreshold = input.float(0.1, "BOS Threshold %", minval=0.01, step=0.01, group="Market Structure") showStructure = input.bool(true, "Show Market Structure", group="Market Structure") showPremiumDiscount = input.bool(true, "Show Premium/Discount Zones", group="Market Structure")

    // Confluence Settings minConfluenceScore = input.int(7, "Minimum Confluence Score", minval=3, maxval=12, group="Confluence") showConfluence = input.bool(true, "Show Confluence Score", group="Confluence")

    // Risk Management - FIXED CRITICAL BUGS riskPercent = input.float(1.0, "Risk % per Trade", minval=0.1, maxval=5, step=0.1, group="Risk Management") maxPositionPercent = input.float(10.0, "Max Position % of Equity", minval=5, maxval=20, group="Risk Management") atrMultiplier = input.float(1.5, "ATR Multiplier for Stops", minval=1.0, step=0.1, group="Risk Management") maxStopATR = input.float(2.0, "Max Stop Distance in ATR", minval=1.0, step=0.5, group="Risk Management") tpRatio1 = input.float(1.5, "TP1 Risk:Reward", minval=1, step=0.5, group="Risk Management") tpRatio2 = input.float(3.0, "TP2 Risk:Reward", minval=2, step=0.5, group="Risk Management") partialPercent = input.float(50, "Partial Close % at TP1", minval=10, maxval=90, step=10, group="Risk Management")

    // Killzone Settings useKillzones = input.bool(true, "Use Killzone Filter", group="Killzones") trackAsianRange = input.bool(true, "Track Asian Range", group="Killzones") asianStart = input.int(0, "Asian Start Hour (UTC)", minval=0, maxval=23, group="Killzones") asianEnd = input.int(3, "Asian End Hour (UTC)", minval=0, maxval=23, group="Killzones") londonStart = input.int(7, "London Start Hour (UTC)", minval=0, maxval=23, group="Killzones") londonEnd = input.int(10, "London End Hour (UTC)", minval=0, maxval=23, group="Killzones") nyStart = input.int(12, "New York Start Hour (UTC)", minval=0, maxval=23, group="Killzones") nyEnd = input.int(16, "New York End Hour (UTC)", minval=0, maxval=23, group="Killzones")

    // ======================================== // MODULE 1: KILLZONES & ASIAN RANGE TRACKING // ======================================== currentHour = hour(time, "Etc/UTC") inAsianKZ = currentHour >= asianStart and currentHour < asianEnd inLondonKZ = currentHour >= londonStart and currentHour < londonEnd inNYKZ = currentHour >= nyStart and currentHour < nyEnd inKillzone = inLondonKZ or inNYKZ or inAsianKZ or not useKillzones

    // Track Asian Range properly var float asianHigh = na var float asianLow = na var float asianOpen = na var bool asianRangeSet = false

    if inAsianKZ and not inAsianKZ[1] // Asian session start asianHigh := high asianLow := low asianOpen := open asianRangeSet := false

    if inAsianKZ asianHigh := math.max(nz(asianHigh, high), high) asianLow := math.min(nz(asianLow, low), low)

    if not inAsianKZ and inAsianKZ[1] // Asian session end asianRangeSet := true

    // ======================================== // MODULE 2: MARKET STRUCTURE (BOS & CHoCH) // ======================================== // Identify swing points swingHigh = ta.pivothigh(high, swingPeriod, swingPeriod) swingLow = ta.pivotlow(low, swingPeriod, swingPeriod)

    // Track recent structure var float lastHigher = na var float lastLower = na var bool bullishStructure = na var bool structureBreak = false

    if not na(swingHigh) if na(lastHigher) or swingHigh > lastHigher lastHigher := swingHigh

    if not na(swingLow) if na(lastLower) or swingLow < lastLower lastLower := swingLow

    // Break of Structure detection bullishBOS = not na(lastHigher) and close > lastHigher * (1 + bosThreshold/100) bearishBOS = not na(lastLower) and close < lastLower * (1 - bosThreshold/100)

    // Change of Character detection if bullishBOS and bullishStructure == false bullishStructure := true structureBreak := true else if bearishBOS and bullishStructure == true bullishStructure := false structureBreak := true else structureBreak := false

    // ======================================== // MODULE 3: PREMIUM/DISCOUNT ZONES (DYNAMIC) // ======================================== // Use session-based ranges when available rangeHigh = trackAsianRange and asianRangeSet and (inLondonKZ or inNYKZ) ? asianHigh : ta.highest(high, rangePeriod) rangeLow = trackAsianRange and asianRangeSet and (inLondonKZ or inNYKZ) ? asianLow : ta.lowest(low, rangePeriod) rangeSize = rangeHigh - rangeLow equilibrium = (rangeHigh + rangeLow) / 2

    premiumZone = rangeLow + (rangeSize * premiumLevel) discountZone = rangeLow + (rangeSize * discountLevel) equilibriumHigh = equilibrium + (rangeSize * equilibriumBand / 2) equilibriumLow = equilibrium - (rangeSize * equilibriumBand / 2)

    isPremium = close > premiumZone isDiscount = close < discountZone isEquilibrium = close <= equilibriumHigh and close >= equilibriumLow

    // ======================================== // MODULE 4: ENHANCED ORDER BLOCKS // ======================================== avgVolume = ta.sma(volume, 20)

    // Corrected bullish OB detection bullishOB = close[1] < open[1] and close > high[1] and volume[1] > avgVolume * obVolumeMultiplier and close > open

    // Corrected bearish OB detection bearishOB = close[1] > open[1] and close < low[1] and volume[1] > avgVolume * obVolumeMultiplier and close < open

    // Track OB levels and mitigation var float bullishOBHigh = na var float bullishOBLow = na var float bearishOBHigh = na var float bearishOBLow = na var bool bullishOBMitigated = false var bool bearishOBMitigated = false var int bullishOBBar = 0 var int bearishOBBar = 0

    if bullishOB bullishOBHigh := high[1] bullishOBLow := low[1] bullishOBMitigated := false bullishOBBar := bar_index - 1

    if bearishOB bearishOBHigh := high[1] bearishOBLow := low[1] bearishOBMitigated := false bearishOBBar := bar_index - 1

    // Check for mitigation if not na(bullishOBLow) and not bullishOBMitigated if low <= bullishOBHigh and low >= bullishOBLow bullishOBMitigated := requireOBMitigation

    if not na(bearishOBHigh) and not bearishOBMitigated if high >= bearishOBLow and high <= bearishOBHigh bearishOBMitigated := requireOBMitigation

    inBullishOB = not na(bullishOBLow) and (bar_index - bullishOBBar < 50) and (requireOBMitigation ? bullishOBMitigated : true) and low <= bullishOBHigh and high >= bullishOBLow

    inBearishOB = not na(bearishOBHigh) and (bar_index - bearishOBBar < 50) and (requireOBMitigation ? bearishOBMitigated : true) and high >= bearishOBLow and low <= bearishOBHigh

    // ======================================== // MODULE 5: LIQUIDITY SWEEPS (JUDAS SWING) // ======================================== // Detect liquidity sweeps with reversal liquiditySweepBull = low < asianLow and close > asianLow and volume > avgVolume * 1.5 and inLondonKZ and asianRangeSet

    liquiditySweepBear = high > asianHigh and close < asianHigh and volume > avgVolume * 1.5 and inLondonKZ and asianRangeSet

    // Track recent sweeps var bool recentBullSweep = false var bool recentBearSweep = false var int bullSweepBar = 0 var int bearSweepBar = 0

    if liquiditySweepBull recentBullSweep := true bullSweepBar := bar_index if liquiditySweepBear recentBearSweep := true bearSweepBar := bar_index

    // Reset after bars if bar_index - bullSweepBar > 10 recentBullSweep := false if bar_index - bearSweepBar > 10 recentBearSweep := false

    // ======================================== // MODULE 6: FAIR VALUE GAPS (WITH MITIGATION) // ======================================== bullishFVG = low > high[2] and close > open bearishFVG = high < low[2] and close < open

    var float lastBullFVGMid = na var float lastBearFVGMid = na var bool bullFVGMitigated = false var bool bearFVGMitigated = false

    if bullishFVG lastBullFVGMid := (low + high[2]) / 2 bullFVGMitigated := false

    if bearishFVG lastBearFVGMid := (low[2] + high) / 2 bearFVGMitigated := false

    // Check FVG mitigation if not na(lastBullFVGMid) and not bullFVGMitigated if low <= lastBullFVGMid bullFVGMitigated := true

    if not na(lastBearFVGMid) and not bearFVGMitigated if high >= lastBearFVGMid bearFVGMitigated := true

    inBullishFVG = bullFVGMitigated and close > lastBullFVGMid inBearishFVG = bearFVGMitigated and close < lastBearFVGMid

    // ======================================== // MODULE 7: ENHANCED CONFLUENCE SCORING // ======================================== bullishScore = 0 bearishScore = 0

    // Zone scoring (most important) bullishScore += isDiscount ? 4 : (isEquilibrium ? 1 : 0) bearishScore += isPremium ? 4 : (isEquilibrium ? 1 : 0)

    // Structure scoring bullishScore += bullishBOS ? 3 : 0 bearishScore += bearishBOS ? 3 : 0 bullishScore += bullishStructure ? 2 : 0 bearishScore += not bullishStructure ? 2 : 0

    // Order block scoring bullishScore += inBullishOB ? 3 : 0 bearishScore += inBearishOB ? 3 : 0

    // Liquidity sweep scoring (Judas Swing) bullishScore += recentBullSweep ? 3 : 0 bearishScore += recentBearSweep ? 3 : 0

    // FVG scoring bullishScore += inBullishFVG ? 2 : 0 bearishScore += inBearishFVG ? 2 : 0

    // Time scoring bullishScore += (inLondonKZ or inNYKZ) ? 1 : 0 bearishScore += (inLondonKZ or inNYKZ) ? 1 : 0

    // ======================================== // MODULE 8: ENTRY CONDITIONS // ======================================== // Additional filters volumeConfirm = volume > avgVolume notFirstMinutes = (minute(time) > 5) or not useKillzones

    longCondition = bullishScore >= minConfluenceScore and strategy.position_size == 0 and not isPremium and volumeConfirm and notFirstMinutes and (bullishStructure or structureBreak)

    shortCondition = bearishScore >= minConfluenceScore and strategy.position_size == 0 and not isDiscount and volumeConfirm and notFirstMinutes and (not bullishStructure or structureBreak)

    // ======================================== // MODULE 9: FIXED RISK MANAGEMENT // ======================================== atr = ta.atr(14)

    // FIXED position sizing function calculatePositionSize(entryPrice, stopLoss) => riskAmount = strategy.equity * (riskPercent / 100) stopDistance = math.abs(entryPrice - stopLoss) // Ensure minimum stop distance stopDistance := math.max(stopDistance, atr * 0.5) posSize = riskAmount / stopDistance // Cap position size to max percentage of equity maxPosSize = (strategy.equity * maxPositionPercent / 100) / entryPrice result = math.min(posSize, maxPosSize) // Ensure positive value math.max(result, 0.01)

    if longCondition entryPrice = close

    text

    // Structure-based stop with OB reference structureStop = na(bullishOBLow) ? lastLower : math.min(lastLower, bullishOBLow) structureStop := na(structureStop) ? low - atr : structureStop

    // Calculate stop with max distance stopLoss = math.max(structureStop - (atr * 0.3), entryPrice - (atr * maxStopATR))

    stopDistance = entryPrice - stopLoss takeProfit1 = entryPrice + (stopDistance * tpRatio1) takeProfit2 = entryPrice + (stopDistance * tpRatio2)

    posSize = calculatePositionSize(entryPrice, stopLoss)

    strategy.entry("Long", strategy.long, qty=posSize) strategy.exit("TP1_Long", "Long", qty_percent=partialPercent, limit=takeProfit1, stop=stopLoss) strategy.exit("TP2_Long", "Long", limit=takeProfit2, stop=stopLoss) if shortCondition entryPrice = close

    text

    // Structure-based stop with OB reference structureStop = na(bearishOBHigh) ? lastHigher : math.max(lastHigher, bearishOBHigh) structureStop := na(structureStop) ? high + atr : structureStop

    // Calculate stop with max distance stopLoss = math.min(structureStop + (atr * 0.3), entryPrice + (atr * maxStopATR))

    stopDistance = stopLoss - entryPrice takeProfit1 = entryPrice - (stopDistance * tpRatio1) takeProfit2 = entryPrice - (stopDistance * tpRatio2)

    posSize = calculatePositionSize(entryPrice, stopLoss)

    strategy.entry("Short", strategy.short, qty=posSize) strategy.exit("TP1_Short", "Short", qty_percent=partialPercent, limit=takeProfit1, stop=stopLoss) strategy.exit("TP2_Short", "Short", limit=takeProfit2, stop=stopLoss) // ======================================== // VISUALIZATION // ======================================== // Premium/Discount zones p1 = plot(showPremiumDiscount ? rangeHigh : na, "Range High", color=color.new(color.red, 70), linewidth=2) p2 = plot(showPremiumDiscount ? premiumZone : na, "Premium Zone", color=color.new(color.red, 85), linewidth=1) p3 = plot(showPremiumDiscount ? equilibrium : na, "Equilibrium", color=color.new(color.gray, 50), linewidth=2, style=plot.style_line) p4 = plot(showPremiumDiscount ? discountZone : na, "Discount Zone", color=color.new(color.green, 85), linewidth=1) p5 = plot(showPremiumDiscount ? rangeLow : na, "Range Low", color=color.new(color.green, 70), linewidth=2)

    fill(p1, p2, color=color.new(color.red, 95), title="Premium Fill") fill(p2, p3, color=color.new(color.gray, 95), title="Equilibrium High") fill(p3, p4, color=color.new(color.gray, 95), title="Equilibrium Low") fill(p4, p5, color=color.new(color.green, 95), title="Discount Fill")

    // Asian Range visualization if trackAsianRange and asianRangeSet and (inLondonKZ or inNYKZ) line.new(bar_index[1], asianHigh, bar_index, asianHigh, color=color.new(color.yellow, 50), width=1, style=line.style_dashed) line.new(bar_index[1], asianLow, bar_index, asianLow, color=color.new(color.yellow, 50), width=1, style=line.style_dashed)

    // Structure points plotshape(not na(swingHigh) and showStructure, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.tiny, offset=-swingPeriod) plotshape(not na(swingLow) and showStructure, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny, offset=-swingPeriod)

    // BOS markers plotshape(bullishBOS and showStructure, style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), text="BOS↑", textcolor=color.white, size=size.small) plotshape(bearishBOS and showStructure, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), text="BOS↓", textcolor=color.white, size=size.small)

    // Killzone backgrounds bgcolor(inLondonKZ ? color.new(color.blue, 95) : na) bgcolor(inNYKZ ? color.new(color.orange, 95) : na) bgcolor(inAsianKZ ? color.new(color.gray, 95) : na)

    // Confluence score label - FIXED SYNTAX var label confluenceLabel = na if showConfluence and barstate.islast if not na(confluenceLabel) label.delete(confluenceLabel)

    text

    zoneText = isPremium ? "PREMIUM" : (isDiscount ? "DISCOUNT" : "EQUILIBRIUM") structureText = bullishStructure ? "BULLISH" : "BEARISH"

    // Fixed string concatenation scoreText = "Zone: " + zoneText + "\n" + "Structure: " + structureText + "\n" + "Bull Score: " + str.tostring(bullishScore) + "\n" + "Bear Score: " + str.tostring(bearishScore)

    labelColor = bullishScore >= minConfluenceScore ? color.green : bearishScore >= minConfluenceScore ? color.red : color.gray

    // Fixed label.new call - all parameters on one line confluenceLabel := label.new(bar_index, high * 1.02, scoreText, color=labelColor, textcolor=color.white, style=label.style_label_down, size=size.small) // Entry signals plotshape(longCondition, style=shape.labelup, location=location.belowbar, color=color.green, text="IPDA\nLONG", textcolor=color.white, size=size.normal) plotshape(shortCondition, style=shape.labeldown, location=location.abovebar, color=color.red, text="IPDA\nSHORT", textcolor=color.white, size=size.normal)

    // Order blocks - FIXED SYNTAX if not na(bullishOBLow) and bar_index - bullishOBBar < 50 box.new(bullishOBBar, bullishOBHigh, bar_index, bullishOBLow, bgcolor=color.new(color.green, 90), border_color=color.green)

    if not na(bearishOBHigh) and bar_index - bearishOBBar < 50 box.new(bearishOBBar, bearishOBHigh, bar_index, bearishOBLow, bgcolor=color.new(color.red, 90), border_color=color.red)

    // Alerts alertcondition(longCondition, title="IPDA Long Signal", message="IPDA Long: Confluence Score Met with Structure Confirmation") alertcondition(shortCondition, title="IPDA Short Signal", message="IPDA Short: Confluence Score Met with Structure Confirmation") alertcondition(liquiditySweepBull or liquiditySweepBear, title="Judas Swing", message="Judas Swing Detected - Potential Reversal") alertcondition(bullishBOS or bearishBOS, title="Break of Structure",

  2. Kimi Assistant

    The Pine Script compiler is very picky about line breaks and line continuation.
    The error

    Syntax error at input 'end of line without line continuation'
    

    means that Pine reached the end of a physical line while it was still inside an unfinished expression or statement.
    In your code the places where this happens are the blocks that start with

    if longCondition
        entryPrice = close
    
    text
    

    and

    if shortCondition
        entryPrice = close
    
    text
    

    The word text is not valid Pine syntax and the interpreter thinks the expression that started with entryPrice = close is still going on, so it throws the “end-of-line-without-line-continuation” error.

    Fix: simply remove the stray word text (or whatever was intended to be there) and make sure each statement finishes on the same line or is continued with the line-continuation character \.

    Below are the corrected snippets:

    if longCondition
        entryPrice = close
    
        // Structure-based stop with OB reference
        structureStop = na(bullishOBLow) ? lastLower : math.min(lastLower, bullishOBLow)
        structureStop := na(structureStop) ? low - atr : structureStop
    
        // Calculate stop with max distance
        stopLoss = math.max(structureStop - (atr * 0.3), entryPrice - (atr * maxStopATR))
    
        stopDistance = entryPrice - stopLoss
        takeProfit1 = entryPrice + (stopDistance * tpRatio1)
        takeProfit2 = entryPrice + (stopDistance * tpRatio2)
    
        posSize = calculatePositionSize(entryPrice, stopLoss)
    
        strategy.entry("Long", strategy.long, qty=posSize)
        strategy.exit("TP1_Long", "Long", qty_percent=partialPercent, limit=takeProfit1, stop=stopLoss)
        strategy.exit("TP2_Long", "Long", limit=takeProfit2, stop=stopLoss)
    
    if shortCondition
        entryPrice = close
    
        // Structure-based stop with OB reference
        structureStop = na(bearishOBHigh) ? lastHigher : math.max(lastHigher, bearishOBHigh)
        structureStop := na(structureStop) ? high + atr : structureStop
    
        // Calculate stop with max distance
        stopLoss = math.min(structureStop + (atr * 0.3), entryPrice + (atr * maxStopATR))
    
        stopDistance = stopLoss - entryPrice
        takeProfit1 = entryPrice - (stopDistance * tpRatio1)
        takeProfit2 = entryPrice - (stopDistance * tpRatio2)
    
        posSize = calculatePositionSize(entryPrice, stopLoss)
    
        strategy.entry("Short", strategy.short, qty=posSize)
        strategy.exit("TP1_Short", "Short", qty_percent=partialPercent, limit=takeProfit1, stop=stopLoss)
        strategy.exit("TP2_Short", "Short", limit=takeProfit2, stop=stopLoss)
    

    After removing the spurious text tokens (and making sure no other statement is split across lines without the \ continuation character), the script will compile without the “end of line without line continuation” error.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.