Pine Script tool
Pine Script Repainting Checker
Paste your Pine Script source below. This scans for the most common patterns that cause an indicator to redraw its historical signals — making backtests look cleaner than live performance ever will be. Nothing is uploaded; the check runs entirely in your browser.
Paste at least 10 characters of Pine Script above to begin the scan.
What repainting is and why it matters
Repainting happens when an indicator's historical values change after the bars they appeared on have already closed. The signal you see on a past bar on today's chart was not there when that bar was live. This is what makes certain indicators appear to predict price with uncanny accuracy in hindsight: they are using information that did not exist at the time the signal supposedly fired.
The consequence for backtesting is severe. A strategy built on a repainting indicator will show a clean equity curve on historical data and then fail immediately in live trading, because the live signals will not match what the backtest implied. The repainting is invisible unless you watch the chart on the close of every bar in real time, or you know what patterns to look for in the code.
The seven patterns this tool checks for
This checker scans for seven structural patterns that are known causes of repainting in Pine Script. They cover the vast majority of real-world cases.
barmerge.lookahead_on is the single most common cause of future data leak in multi-timeframe indicators. It tells request.security to use the value of the higher-timeframe bar before it closes.
request.security without [1] offset reads the current, unfinished higher-timeframe bar. The bar's value changes on every tick, so a signal that fires near the end of a historical bar may not fire at the same point live.
barstate.isrealtime in conditions creates logic that runs differently on historical bars than on live ones, guaranteeing that the backtest and the live chart disagree.
varip variables in signal conditions update on every tick during a live bar, but historical bars execute only once. A condition based on a varip value can fire mid-bar live but never fire at that point in a backtest.
ta.pivothigh / ta.pivotlow without na check are safe functions but are frequently used incorrectly. Pivot confirmation is delayed by design, and acting on the raw return value without checking for na can produce signals that appear to paint at a past bar, then disappear.
For a complete explanation of all five kinds of repainting in Pine Script, including the two this tool cannot detect statically, see the full repainting guide.
What this tool cannot check
Static pattern matching cannot detect repainting that arises from logic rather than structure. An indicator that stores a value in a var variable on the current bar based on future information, or one that uses barstate.isconfirmed correctly on the surface but processes the result in a way that still depends on the current unfinished bar, will not be caught here. A clean scan is a strong positive signal, not a guarantee. The only definitive test is watching the indicator on a live chart at the close of several bars and checking whether historical signals remain stable.
Write non-repainting Pine Script from the start
The hardest part of building a non-repainting multi-timeframe indicator is knowing the correct request.security pattern before you start, not debugging it afterward. The code above shows the confirmed-bar pattern: reading the expression with [1] and setting lookahead to off so the indicator only ever sees closed bars.
Describing this requirement in plain English to PineScripter produces code that uses this pattern by default, so you never paste an indicator into TradingView and discover two weeks later that it was repainting all along.
//@version=6
indicator("Non-repainting MTF close", overlay=true)
// Safe: reads the last CONFIRMED daily close using [1].
// Without [1], the value would update every tick during the live daily bar.
htfClose = request.security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_off)
plot(htfClose, "Confirmed daily close", color=color.aqua)PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.