Skip to content

teaceo-debug/DEEP6 / .claude/skills/tradingview-pinescript-error-doctor

tradingview-pinescript-error-doctor

Verified

patterns/quick-fixes.md

View on GitHub
# Quick Fixes Library

Last verified: 2026-05-22

Reference source: `C:\Users\Tea\DEEP6\skills\tradingview-pine-debugging-mastery.md`

Use these as surgical repair snippets, not as an excuse to avoid root-cause analysis.

## 1. Early bar guard

```pine
ready = bar_index >= length
val = ready ? close[length] : na
```

## 2. Array access guard

```pine
val = array.size(a) > i and i >= 0 ? array.get(a, i) : na
```

## 3. Object setter guard

```pine
if not na(l)
    line.set_y1(l, price)
```

## 4. Last-bar table update

```pine
var table t = table.new(position.top_right, 2, 2)
if barstate.islast
    table.cell(t, 0, 0, "Status")
```

## 5. Candle-locked label

```pine
label.new(time, high, "X", xloc = xloc.bar_time, yloc = yloc.price)
```

## 6. Non-repainting confirmed alert

```pine
sig = ta.crossover(close, ta.sma(close, 20))
alertcondition(sig and barstate.isconfirmed, "Signal", "Signal")
```

## 7. Dynamic `barsAgo` from target bar index

```pine
targetBar = ta.valuewhen(sig, bar_index, 0)
barsAgo = bar_index - targetBar
valid = not na(targetBar) and barsAgo >= 0 and barsAgo <= bar_index and barsAgo <= 5000
priceAtSignal = valid ? close[barsAgo] : na
```

## 8. Reverse array deletion pattern

```pine
for i = array.size(labels) - 1 to 0
    lbl = array.get(labels, i)
    if shouldDelete(lbl)
        label.delete(lbl)
        array.remove(labels, i)
```

Use reverse iteration when removing multiple elements from arrays.

## 9. `na` comparison rule

```pine
if na(x)
    x := close
```

Do not use `x == na` or `x != na`.

## 10. Safe `request.security()` with confirmed data

```pine
htfPrevClose = request.security(syminfo.tickerid, "15", close[1], lookahead = barmerge.lookahead_off)
```

## 11. Max-count cleanup with shift/delete

```pine
if array.size(eventBoxes) > maxBoxes
    oldBox = array.shift(eventBoxes)
    if not na(oldBox)
        box.delete(oldBox)
```

## 12. Loop-bound guard for empty arrays

```pine
if array.size(a) > 0
    for i = 0 to array.size(a) - 1
        process(array.get(a, i))
```

Without the outer guard, `array.size(a) - 1` can become an invalid upper bound.
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall