Why Your Multi-Time frame Indicator Repaints (And How I Fix It)

Why Your Multi-Timeframe Indicator Repaints (And How I Fix It) – Jayadev Rana

A Deep Dive into Pine Script Stability by Jayadev Rana


Imagine this scenario:

You find a “Holy Grail” strategy on TradingView. The backtest results are incredible—90% win rate, massive profits, and zero drawdowns. You excitedly switch it on for live trading, dreaming of passive income.

The Reality Check: Within an hour, your account is bleeding money. The “Buy” signal that appeared on the chart 10 minutes ago suddenly vanishes into thin air.

Welcome to the nightmare of Repainting. As a Pine Script Expert Freelancer, the most common request I get is: “Jayadev, can you fix this indicator? It cheats.”

Today, I’m going to pull back the curtain on why this happens and how a professional developer fixes it.

The “Crystal Ball” Glitch

Repainting occurs when a script “looks into the future” to calculate past data. It’s like betting on a horse race after you already know who won.

In Pine Script, this usually happens with the powerful but dangerous function: request.security().

The Dangerous Code (Do Not Use This)

//@version=5
// WARNING: This script repaints!
indicator("Repainting MTF Example", overlay=true)

// Getting Daily Close on a 1-Hour Chart
dailyClose = request.security(syminfo.tickerid, "D", close)

plot(dailyClose)

If you run this code on a 1-hour chart at 10:00 AM, the script already grabs the Closing Price of the day (which hasn’t happened yet in real-time). This creates fake “perfect” signals that disappear in live markets.

The 3 Types of Repainting

Most traders think repainting is just one thing. It’s actually three different bugs:

  1. Future Leak Repainting: Using `request.security` without proper offsets. The script reads data from higher timeframes that hasn’t closed yet.
  2. Real-Time Repainting: Indicators that calculate on every tick (price update). A crossover might happen at 10:14 AM, but by 10:15 AM (candle close), the price dropped and the crossover was invalidated.
  3. Offset Repainting: Using negative offsets like `plot(close, offset=-5)`. This literally draws lines in the past.

How I Code “Non-Repainting” Scripts

When clients hire me for Custom TradingView Indicator Development, reliability is my #1 deliverable. I don’t build scripts that lie.

The Golden Rule: If you are on a 5-minute chart, you should only ask the Daily timeframe for data from Yesterday (or the previous completed candle), not the current moving candle.

The Reliable Solution

//@version=5
// SUCCESS: This script does NOT repaint.
indicator("Reliable MTF Example", overlay=true)

// We use 'barmerge.lookahead_on' carefully, 
// AND we reference the previous bar [1]
dailyClose = request.security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_on)

plot(dailyClose)

By adding [1], we tell the script: “Only show me the data that has actually closed.” The signals might look slightly less perfect on history, but they will work 100% correctly in live trading.

Frequently Asked Questions

1. Can any repainting indicator be fixed?
In 95% of cases, yes. We simply need to adjust the logic to stop “peeking” at future data. However, this often lowers the win rate shown in backtests because the “fake” wins are removed.
2. Does repainting affect automated trading?
Yes, disastrously. Your bot might open a trade based on a signal, but if that signal vanishes 5 minutes later, your bot is left holding a bad position with no exit signal.
3. What is the ‘barmerge.lookahead’ warning?
TradingView issues a warning when using lookahead because it is risky. However, experienced developers know how to use it safely (using historical offsets) to optimize script speed without repainting.
4. Why do my alerts fire but the chart shows nothing?
This happens when your script is set to “Once Per Bar Close” but your logic is calculating on “Every Tick.” You need a developer to synchronize your alert conditions with your plot logic.
5. Is Heikin Ashi considered repainting?
Technically, no. But Heikin Ashi candles are synthetic—they don’t represent the actual trade price. Strategies built on Heikin Ashi often fail in real life because the entry price shown never existed.
6. How much does it cost to fix a script?
It depends on the complexity (lines of code). Simple fixes are very affordable, while restructuring a complex strategy takes more time. Contact me for a quick quote.
7. Can you verify if a script repaints before I buy it?
Absolutely. I offer a “Code Audit” service where I review third-party scripts to ensure they are safe and honest before you risk your capital.

Stop Trading with Phantom Signals

Your capital is too valuable to risk on buggy code. A strategy that repaints is not a strategy—it’s a trap.

Do you have a Multi-Timeframe Indicator that seems too good to be true? Or perhaps you need a custom strategy built from scratch?

>> Hire Me to Fix Your Script