Skip to content
TheChatArchiveThe Chat Archive
Amazon Novaamazon-nova-experimental-chat-05-14· AmazonHugging Face LMArena Human Preference 140K

Here's the final Pine Script v6 indicator that highlights higher timeframe candles where…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-sonnet-4-20250514-thinking-32k’s answer.
  1. User

    Here's the final Pine Script v6 indicator that highlights higher timeframe candles where the current candle's high or low breaches the previous candle's high or low, and the current candle closes within the previous candle's range:

    //@version=6
    indicator("Candle Breach Indicator", overlay=true)
    
    // Input for higher timeframe
    higherTF = input.timeframe("D", "Higher Timeframe")
    
    // Request higher timeframe data
    higherOpen = request.security(syminfo.tickerid, higherTF, open)
    higherHigh = request.security(syminfo.tickerid, higherTF, high)
    higherLow = request.security(syminfo.tickerid, higherTF, low)
    higherClose = request.security(syminfo.tickerid, higherTF, close)
    higherTimeOpen = request.security(syminfo.tickerid, higherTF, time)
    higherTimeClose = request.security(syminfo.tickerid, higherTF, time_close)
    
    // Calculate the condition on the higher timeframe
    prevHigh = request.security(syminfo.tickerid, higherTF, high[1])
    prevLow = request.security(syminfo.tickerid, higherTF, low[1])
    prevClose = request.security(syminfo.tickerid, higherTF, close[1])
    
    currentHigh = higherHigh
    currentLow = higherLow
    currentClose = higherClose
    
    breachHigh = currentHigh > prevHigh
    breachLow = currentLow < prevLow
    closeWithinRange = currentClose <= prevHigh and currentClose >= prevLow
    
    condition = (breachHigh or breachLow) and closeWithinRange
    
    // Keep track of the last processed higher timeframe bar's open time to avoid duplicate boxes
    var float lastProcessedTime = na
    
    // Check if the current higher timeframe bar meets the condition and hasn't been processed yet
    if condition and (na(lastProcessedTime) or higherTimeOpen != lastProcessedTime)
        box.new(
             left=higherTimeOpen,
             right=higherTimeClose,
             top=higherHigh,
             bottom=higherLow,
             border_color=color.red,
             border_width=2,
             bgcolor=color.new(color.red, 90)
         )
        lastProcessedTime := higherTimeOpen
    

    This script will highlight the specified higher timeframe candles on the lower timeframe chart with rectangles. The user can adjust the higher timeframe using the input settings.when i run this i get error of cant draw max 500 bars (i chose the 60 minutes

  2. Amazon Nova Assistant

    The error you're encountering, "Cannot draw more than 500 boxes," is due to TradingView's limit on the number of graphical objects (like boxes) that can be drawn on a chart. To address this, we need to implement a strategy to limit the number of boxes drawn. Here are a few methods to resolve this issue:

    Method 1: Limit the Number of Boxes Drawn

    We can add a counter to ensure that no more than 500 boxes are drawn. This method will stop drawing boxes after the limit is reached.

    //@version=6
    indicator("Candle Breach Indicator", overlay=true)
    
    // Input for higher timeframe
    higherTF = input.timeframe("60", "Higher Timeframe")
    
    // Request higher timeframe data
    higherOpen = request.security(syminfo.tickerid, higherTF, open)
    higherHigh = request.security(syminfo.tickerid, higherTF, high)
    higherLow = request.security(syminfo.tickerid, higherTF, low)
    higherClose = request.security(syminfo.tickerid, higherTF, close)
    higherTimeOpen = request.security(syminfo.tickerid, higherTF, time)
    higherTimeClose = request.security(syminfo.tickerid, higherTF, time_close)
    
    // Calculate the condition on the higher timeframe
    prevHigh = request.security(syminfo.tickerid, higherTF, high[1])
    prevLow = request.security(syminfo.tickerid, higherTF, low[1])
    prevClose = request.security(syminfo.tickerid, higherTF, close[1])
    
    currentHigh = higherHigh
    currentLow = higherLow
    currentClose = higherClose
    
    breachHigh = currentHigh > prevHigh
    breachLow = currentLow < prevLow
    closeWithinRange = currentClose <= prevHigh and currentClose >= prevLow
    
    condition = (breachHigh or breachLow) and closeWithinRange
    
    // Keep track of the last processed higher timeframe bar's open time to avoid duplicate boxes
    var float lastProcessedTime = na
    // Counter to limit the number of boxes drawn
    var int boxCount = 0
    var int maxBoxes = 500
    
    // Check if the current higher timeframe bar meets the condition and hasn't been processed yet
    if condition and (na(lastProcessedTime) or higherTimeOpen != lastProcessedTime) and boxCount < maxBoxes
        box.new(
             left=higherTimeOpen,
             right=higherTimeClose,
             top=higherHigh,
             bottom=higherLow,
             border_color=color.red,
             border_width=2,
             bgcolor=color.new(color.red, 90)
         )
        lastProcessedTime := higherTimeOpen
        boxCount := boxCount + 1
    

    Method 2: Only Draw Boxes for Recent Bars

    Another approach is to only draw boxes for the most recent bars. This can be done using the barstate.islast variable to ensure that boxes are only drawn for the last 500 bars.

    //@version=6
    indicator("Candle Breach Indicator", overlay=true)
    
    // Input for higher timeframe
    higherTF = input.timeframe("60", "Higher Timeframe")
    
    // Request higher timeframe data
    higherOpen = request.security(syminfo.tickerid, higherTF, open)
    higherHigh = request.security(syminfo.tickerid, higherTF, high)
    higherLow = request.security(syminfo.tickerid, higherTF, low)
    higherClose = request.security(syminfo.tickerid, higherTF, close)
    higherTimeOpen = request.security(syminfo.tickerid, higherTF, time)
    higherTimeClose = request.security(syminfo.tickerid, higherTF, time_close)
    
    // Calculate the condition on the higher timeframe
    prevHigh = request.security(syminfo.tickerid, higherTF, high[1])
    prevLow = request.security(syminfo.tickerid, higherTF, low[1])
    prevClose = request.security(syminfo.tickerid, higherTF, close[1])
    
    currentHigh = higherHigh
    currentLow = higherLow
    currentClose = higherClose
    
    breachHigh = currentHigh > prevHigh
    breachLow = currentLow < prevLow
    closeWithinRange = currentClose <= prevHigh and currentClose >= prevLow
    
    condition = (breachHigh or breachLow) and closeWithinRange
    
    // Keep track of the last processed higher timeframe bar's open time to avoid duplicate boxes
    var float lastProcessedTime = na
    
    // Check if the current higher timeframe bar meets the condition and hasn't been processed yet
    if barstate.islast and condition and (na(lastProcessedTime) or higherTimeOpen != lastProcessedTime)
        box.new(
             left=higherTimeOpen,
             right=higherTimeClose,
             top=higherHigh,
             bottom=higherLow,
             border_color=color.red,
             border_width=2,
             bgcolor=color.new(color.red, 90)
         )
        lastProcessedTime := higherTimeOpen
    

    Method 3: Delete Older Boxes

    This method involves keeping track of all created boxes and deleting the oldest ones when the limit is reached. This ensures that only the most recent 500 boxes are displayed.

    //@version=6
    indicator("Candle Breach Indicator", overlay=true)
    
    // Input for higher timeframe
    higherTF = input.timeframe("60", "Higher Timeframe")
    
    // Request higher timeframe data
    higherOpen = request.security(syminfo.tickerid, higherTF, open)
    higherHigh = request.security(syminfo.tickerid, higherTF, high)
    higherLow = request.security(syminfo.tickerid, higherTF, low)
    higherClose = request.security(syminfo.tickerid, higherTF, close)
    higherTimeOpen = request.security(syminfo.tickerid, higherTF, time)
    higherTimeClose = request.security(syminfo.tickerid, higherTF, time_close)
    
    // Calculate the condition on the higher timeframe
    prevHigh = request.security(syminfo.tickerid, higherTF, high[1])
    prevLow = request.security(syminfo.tickerid, higherTF, low[1])
    prevClose = request.security(syminfo.tickerid, higherTF, close[1])
    
    currentHigh = higherHigh
    currentLow = higherLow
    currentClose = higherClose
    
    breachHigh = currentHigh > prevHigh
    breachLow = currentLow < prevLow
    closeWithinRange = currentClose <= prevHigh and currentClose >= prevLow
    
    condition = (breachHigh or breachLow) and closeWithinRange
    
    // Keep track of the last processed higher timeframe bar's open time to avoid duplicate boxes
    var float lastProcessedTime = na
    // Array to store box IDs
    var box[] boxes = array.new_box()
    var int maxBoxes = 500
    
    // Check if the current higher timeframe bar meets the condition and hasn't been processed yet
    if condition and (na(lastProcessedTime) or higherTimeOpen != lastProcessedTime)
        if array.size(boxes) >= maxBoxes
            oldestBox = array.shift(boxes)
            box.delete(oldestBox)
        newBox = box.new(
             left=higherTimeOpen,
             right=higherTimeClose,
             top=higherHigh,
             bottom=higherLow,
             border_color=color.red,
             border_width=2,
             bgcolor=color.new(color.red, 90)
         )
        array.push(boxes, newBox)
        lastProcessedTime := higherTimeOpen
    

    Method 4: Use Labels Instead of Boxes

    If you don't need the exact rectangle shape, you can use label.new() to plot a small label on the candle. This method won't hit the 500-object limit because labels are not counted towards the 500-object limit in the same way boxes are.

    //@version=6
    indicator("Candle Breach Indicator", overlay=true)
    
    // Input for higher timeframe
    higherTF = input.timeframe("60", "Higher Timeframe")
    
    // Request higher timeframe data
    higherOpen = request.security(syminfo.tickerid, higherTF, open)
    higherHigh = request.security(syminfo.tickerid, higherTF, high)
    higherLow = request.security(syminfo.tickerid, higherTF, low)
    higherClose = request.security(syminfo.tickerid, higherTF, close)
    higherTimeOpen = request.security(syminfo.tickerid, higherTF, time)
    higherTimeClose = request.security(syminfo.tickerid, higherTF, time_close)
    
    // Calculate the condition on the higher timeframe
    prevHigh = request.security(syminfo.tickerid, higherTF, high[1])
    prevLow = request.security(syminfo.tickerid, higherTF, low[1])
    prevClose = request.security(syminfo.tickerid, higherTF, close[1])
    
    currentHigh = higherHigh
    currentLow = higherLow
    currentClose = higherClose
    
    breachHigh = currentHigh > prevHigh
    breachLow = currentLow < prevLow
    closeWithinRange = currentClose <= prevHigh and currentClose >= prevLow
    
    condition = (breachHigh or breachLow) and closeWithinRange
    
    // Keep track of the last processed higher timeframe bar's open time to avoid duplicate labels
    var float lastProcessedTime = na
    
    // Check if the current higher timeframe bar meets the condition and hasn't been processed yet
    if condition and (na(lastProcessedTime) or higherTimeOpen != lastProcessedTime)
        label.new(
             x=higherTimeOpen,
             y=higherHigh,
             text="B",
             color=color.red,
             style=label.style_label_down,
             size=size.small
         )
        lastProcessedTime := higherTimeOpen
    

    Choose the method that best fits your needs. If you prefer the exact rectangle shape, use Method 3. If a simpler visualisation is acceptable Method 4 is the easiest solution.

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