OPEN-SOURCE SCRIPT
Safe Supertrend Strategy (No Repaint)

Overview
The Safe Supertrend is a repaint-free version of the popular Supertrend trend-following indicator.
Most Supertrend indicators appear perfect on historical charts because they flip intrabar and then repaint after the candle closes.
This version fixes that by using close-of-bar confirmation only, making every trend flip 100% stable, safe, and non-repainting.
Why This Supertrend Doesn’t Repaint
Most Supertrend indicators calculate their trend direction using the current bar’s data.
But during a live candle:
That is classic repainting.
This indicator avoids all of that by using:
close[1] > upper[1]
close[1] < lower[1]
This means:
Every signal you see on the chart is exactly what was available in real-time.
How It Works
No repainting, no recalc, no misleading flips.
Bullish Signal (Trend Up)
A bullish trend begins only when:
A green triangle marks the start of a new uptrend.
Bearish Signal (Trend Down)
A bearish trend begins only when:
A red triangle signals the start of a new downtrend.
Inputs
Simple, but powerful.
Why Use This Version Instead of a Regular Supertrend?
Most Supertrends:
This version:
Ideal For:
Final Note
This is a safer, more reliable Supertrend designed for real-world use — not perfect-looking repaint illusions.
If you use Supertrend in your trading system, this no-repaint version ensures your signals are trustworthy and consistent.
The Safe Supertrend is a repaint-free version of the popular Supertrend trend-following indicator.
Most Supertrend indicators appear perfect on historical charts because they flip intrabar and then repaint after the candle closes.
This version fixes that by using close-of-bar confirmation only, making every trend flip 100% stable, safe, and non-repainting.
Why This Supertrend Doesn’t Repaint
Most Supertrend indicators calculate their trend direction using the current bar’s data.
But during a live candle:
- ATR expands and contracts
- The upper/lower bands move
- Price moves above/below the band temporarily
- A false flip appears → then disappears when the candle closes
That is classic repainting.
This indicator avoids all of that by using:
close[1] > upper[1]
close[1] < lower[1]
This means:
- Trend direction flips only based on the previous candle,
- No intrabar calculations,
- No flickering signals,
- No “perfect but fake” historical performance.
Every signal you see on the chart is exactly what was available in real-time.
How It Works
- Calculates ATR (Average True Range) and SMA centerline
- Builds upper and lower volatility bands
- Confirms trend flips only after the previous bar closes
- Plots clear bull and bear reversal signals
- Works on all markets (crypto, stocks, forex, indices)
No repainting, no recalc, no misleading flips.
Bullish Signal (Trend Up)
A bullish trend begins only when:
- The previous candle closes above the upper ATR band,
- And this flip is fully confirmed.
A green triangle marks the start of a new uptrend.
Bearish Signal (Trend Down)
A bearish trend begins only when:
- The previous candle closes below the lower ATR band,
- And the downtrend is confirmed.
A red triangle signals the start of a new downtrend.
Inputs
- ATR Length - default 10
- ATR Multiplier - default 3.0
- Works on all timeframes and market
Simple, but powerful.
Why Use This Version Instead of a Regular Supertrend?
Most Supertrends:
- Look great historically
- But repaint continuously on live charts
- Give false trend flips intrabar
- Cannot be reliably used in strategies
This version:
- Uses strict previous-bar logic
- Never repaints trend direction
- Works perfectly in live trading
- Backtests accurately
- Is ideal for algorithmic strategies
Ideal For:
- Trend-following strategies
- Breakout trading
- Algo trading systems
- Reversal detection
- Filtering market noise
- Swing trading & scalping
Final Note
This is a safer, more reliable Supertrend designed for real-world use — not perfect-looking repaint illusions.
If you use Supertrend in your trading system, this no-repaint version ensures your signals are trustworthy and consistent.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.