Here is a companion for that one or stand alone.
Perfect Supertrend Line
The Perfect SuperTrend Line is an adaptive dual-line trend model designed to identify directional bias with high clarity and minimal noise.
It uses two dynamically adjusting levels:
• A Slow Line – establishes the primary trend by tracking recent structural highs/lows.
• A Fast Line – provides early momentum detection and helps confirm or weaken the current trend state.
A trend shift occurs only when price closes on the same side of both lines, helping reduce false reversals. Cyan indicates bullish conditions, while magenta/red indicates bearish conditions.
Up/down arrows appear at the slow line level when a confirmed trend reversal is detected.
How to Use:
• Trade only in the direction of the active trend color.
• Look for pullbacks toward the Fast Line after a new arrow for higher-probability entries.
• Conservative exits: opposite arrow.
• Aggressive exits: price closes against the Fast Line.
Recommended Timeframes:
• Best for 5m–15m intraday charts and 30m–1H swing trades.
• Higher timeframes (4H–Daily) provide the cleanest structural trends with fewer whipsaws.
• Lower timeframes (1–2m) work but may generate noise.
Ideal For:
• Trend-following entries
• Pullback trading
• Swing confirmation
• Filtering low-quality trades
Perfect Supertrend Line
The Perfect SuperTrend Line is an adaptive dual-line trend model designed to identify directional bias with high clarity and minimal noise.
It uses two dynamically adjusting levels:
• A Slow Line – establishes the primary trend by tracking recent structural highs/lows.
• A Fast Line – provides early momentum detection and helps confirm or weaken the current trend state.
A trend shift occurs only when price closes on the same side of both lines, helping reduce false reversals. Cyan indicates bullish conditions, while magenta/red indicates bearish conditions.
Up/down arrows appear at the slow line level when a confirmed trend reversal is detected.
How to Use:
• Trade only in the direction of the active trend color.
• Look for pullbacks toward the Fast Line after a new arrow for higher-probability entries.
• Conservative exits: opposite arrow.
• Aggressive exits: price closes against the Fast Line.
Recommended Timeframes:
• Best for 5m–15m intraday charts and 30m–1H swing trades.
• Higher timeframes (4H–Daily) provide the cleanest structural trends with fewer whipsaws.
• Lower timeframes (1–2m) work but may generate noise.
Ideal For:
• Trend-following entries
• Pullback trading
• Swing confirmation
• Filtering low-quality trades
Code:
# Perfect Supertrend Line V1
# By CANDO13579
declare upper;
input fastLength = 3;
input slowLength = 7;
def na = Double.NaN;
# Slow line calculation
def slow_line;
if (IsNaN(slow_line[1])) {
slow_line = close;
} else {
if (close > slow_line[1]) {
slow_line = Lowest(low, slowLength);
} else {
slow_line = Highest(high, slowLength);
}
}
# Fast line calculation
def fast_line;
if (IsNaN(fast_line[1])) {
fast_line = close;
} else {
if (close > fast_line[1]) {
fast_line = Lowest(low, fastLength);
} else {
fast_line = Highest(high, fastLength);
}
}
# Trend calculation
def trend;
if (IsNaN(trend[1])) {
trend = 0;
} else {
if (close < slow_line and close < fast_line) {
trend = 1;
} else if (close > slow_line and close > fast_line) {
trend = 0;
} else {
trend = trend[1];
}
}
# Arrow positions
def arrow_pos = if trend != trend[1] then slow_line else na;
# Slow line conditions
plot SlowUpLine = if trend == 0 then slow_line else na;
SlowUpLine.SetDefaultColor(Color.CYAN);
SlowUpLine.SetLineWeight(2);
SlowUpLine.SetStyle(Curve.FIRM);
plot SlowDownLine = if trend == 1 then slow_line else na;
SlowDownLine.SetDefaultColor(Color.MAGENTA);
SlowDownLine.SetLineWeight(2);
SlowDownLine.SetStyle(Curve.FIRM);
# Fast line with conditional coloring
plot FastLine = fast_line;
FastLine.AssignValueColor(if trend == 0 then Color.CYAN else Color.RED);
FastLine.SetLineWeight(1);
FastLine.SetStyle(Curve.POINTS);
# Arrow shapes
plot UpArrow = if trend == 0 and !IsNaN(arrow_pos) then arrow_pos else na;
UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpArrow.SetDefaultColor(Color.CYAN);
plot DownArrow = if trend == 1 and !IsNaN(arrow_pos) then arrow_pos else na;
DownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownArrow.SetDefaultColor(Color.RED);
Last edited by a moderator: