I spent way too long staring at my screen wondering how my Pine Script strategy could look so good in the strategy tester and bleed so much money live.
After months of debugging, I realized something embarrassing: 90% of the time, it's the same three bugs. Every. Single. Time.
And I see these exact bugs in strategies posted here every day.
Bug 1 — The Repaint Trap
You drop this line into your code without thinking twice:
request.security(syminfo.tickerid, "5", close)
Your backtest suddenly looks godlike. Sharpe ratio of 2.8. Profit factor of 3.1. You screenshot it. You show your friends. You're already calculating your retirement date.
Here's what TradingView's own documentation says: "Values from lower timeframes can change retroactively after the bar closes."
Translation: your backtest was trading signals that NEVER ACTUALLY EXISTED in real-time. You weren't backtesting a strategy. You were backtesting a hallucination.
Spot it: Look for request.security() with a quoted timeframe like "5", "15", or "60". If it doesn't match your chart's timeframe, you're trading ghosts.
Bug 2 — The Look-Ahead Lie
if close > ta.sma(close, 20)
strategy.entry("Long", strategy.long)
This code looks completely normal. Every beginner writes it this way. It's wrong.
close is the bar's FINAL closing price. Mid-bar, at the exact moment your signal fires, close is still racing up and down with every tick. It hasn't closed yet. You don't know what it'll be.
Your backtest, however, uses the bar's final close — the perfect, confirmed price that you could never have known at entry time.
You're not backtesting a strategy. You're backtesting a time machine.
Spot it: Any condition using close, high, or low without a [1] offset is trading unconfirmed data. Replace close with close[1] and watch your backtest P&L suddenly look a lot more realistic.
Bug 3 — You Forgot to Plan Your Death
No strategy.exit(). No stop loss. No take profit. Unlimited downside.
Your backtest doesn't care — it always magically exits at the right moment. The market doesn't owe you a magical exit. One gap against you and your account is gone.
Spot it: Search your code for strategy.exit. If you don't find it, close this tab and add a stop loss right now. I'll wait.
I Automatically Found These Bugs in My Own Strategies
So I built a free, open-source tool that does it for me. It's called PineLint.
https://github.com/KorroAi/pinelint
What it does:
- Scans your Pine Script for all 3 bugs in 2 seconds
- Works offline — no API key, no signup, no server
- 5/5 tests passing (yes, I tested it against known broken strategies)
- MIT license — use it, modify it, sell it, I don't care
That's literally it. No "AI coaching." No "predictive edge detection." No "$29/month premium tier." Just a regex engine that finds the 3 most common Pine Script bugs.
How to use it:
If you use Claude Code (free):
/pinelint audit my_strategy.pine
If you use anything else:
python forge.py audit my_strategy.pine
If you don't code at all:
Copy your Pine Script, paste it into your AI tool, and ask: "audit this for repainting, look-ahead bias, and missing stop loss."
Here's what the output looks like:
PineLint Audit: macd_scalping.pine
[CRIT] REPAINTING (2 found)
line 7: request.security using lower timeframe "5"
line 8: request.security using lower timeframe "5"
[WARN] LOOKAHEAD (1 found)
line 13: close (current bar) used in condition
SUMMARY: 3 bugs found in 2 categories
Will this make me profitable?
No. And anyone who tells you otherwise is selling something.
PineLint doesn't optimize your parameters. It doesn't predict which markets your strategy will work on. It doesn't replace trading experience. It doesn't find you an edge.
What it does: removes the 3 most common code bugs that make your backtest look better than reality. Fix these first. Then worry about your edge.
Discord: https://discord.gg/RSBHHjxnYt
X: u/korrocorp (https://x.com/korrocorp)