Uptrick: Band Flow is a trend overlay built from a smoothed moving-average baseline and ATR bands. The trend only changes when a bar closes outside the opposite band, so the trend color holds while price moves inside the envelope. When the trend changes, the script prints one Up or Down label and tracks five ATR-based target levels from the entry close.
It includes entry levels, and five target levels. I added a stop loss zone which is the dark red and magenta areas. Labels indicate entry price and targets hit.
Original concept: https://www.tradingview.com/script/QqSFhZiX-Uptrick-Band-Flow/
In the below example of /NQ on the 2 hour chart, notice that price hit the 3 target level 5 times in a row.
It includes entry levels, and five target levels. I added a stop loss zone which is the dark red and magenta areas. Labels indicate entry price and targets hit.
Original concept: https://www.tradingview.com/script/QqSFhZiX-Uptrick-Band-Flow/
In the below example of /NQ on the 2 hour chart, notice that price hit the 3 target level 5 times in a row.
Code:
# Uptrick: Band Flow
# Original concept: https://www.tradingview.com/script/QqSFhZiX-Uptrick-Band-Flow/
# Converted and modified by Chewie 9/21/2026
declare upper;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 01. TREND ENGINE INPUTS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
input trendLength = 30;
input trendSmoothing = 4;
input atrLength = 14;
input upperMult = 1.50;
input lowerMult = 1.50;
input upperMult2 = 2.50;
input lowerMult2 = 2.50;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 02. OVERLAY INPUTS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
input overlayMode = { default "Bands", "Center", "Trail" };
input trailOuterATR = 0.85;
input trailSmoothing = 5;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 03. SIGNAL ANCHOR INPUTS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
input signalAnchorMode = { default "Bands", "ATR" };
input signalATRLength = 14;
input signalATRMult = 0.80;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 04. ATR TAKE PROFIT INPUTS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
input showATRTP = yes;
input tpn2Mult = -2.0;
input tpn1Mult = -1.0;
input tp1Mult = 1.0;
input tp2Mult = 2.0;
input tp3Mult = 3.0;
input tp4Mult = 4.0;
input tp5Mult = 5.0;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 05. DISPLAY INPUTS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
input showSignals = yes;
input showCandles = yes;
input showLabels = yes;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# GLOBAL COLORS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DefineGlobalColor("Bull", CreateColor(0, 255, 229));
DefineGlobalColor("Bear", CreateColor(255, 0, 181));
DefineGlobalColor("BullCloudFade", CreateColor(0, 80, 72));
DefineGlobalColor("BearCloudFade", CreateColor(80, 0, 57));
DefineGlobalColor("White", CreateColor(255, 255, 255));
DefineGlobalColor("yellow", CreateColor(255, 255, 100));
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# TREND BASELINE
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
def baseWMA = WMA(close, trendLength);
def basis = if trendSmoothing > 1 then ExpAverage(baseWMA, trendSmoothing) else baseWMA;
def rawATR = WildersAverage(TrueRange(high, close, low), atrLength);
def safeATR = if rawATR > TickSize() then rawATR else TickSize();
def upperBand = basis + safeATR * upperMult;
def lowerBand = basis - safeATR * lowerMult;
def upperBand2 = basis + safeATR * upperMult2;
def lowerBand2 = basis - safeATR * lowerMult2;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# TREND STATE
# bullBreak / bearBreak fire on the bar close that crosses the band.
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
def bullBreak = close > upperBand and close[1] <= upperBand[1];
def bearBreak = close < lowerBand and close[1] >= lowerBand[1];
def trend = CompoundValue(1,
if bullBreak then 1
else if bearBreak then -1
else if trend[1] != 0 then trend[1]
else if close >= basis then 1 else -1,
if close >= basis then 1 else -1);
def bullish = trend == 1;
def bearish = trend == -1;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# TRAIL GEOMETRY
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
def smoothTrailBasis = if trailSmoothing > 1 then ExpAverage(basis, trailSmoothing) else basis;
def smoothTrailATR = if trailSmoothing > 1 then ExpAverage(safeATR, trailSmoothing) else safeATR;
def trailInner = if bullish
then basis - safeATR * lowerMult
else basis + safeATR * upperMult;
def trailOuter = if bullish
then smoothTrailBasis - smoothTrailATR * (lowerMult + trailOuterATR)
else smoothTrailBasis + smoothTrailATR * (upperMult + trailOuterATR);
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# SIGNAL ANCHOR ENGINE
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
def signalRawATR = WildersAverage(TrueRange(high, close, low), signalATRLength);
def safeSignalATR = if signalRawATR > TickSize() then signalRawATR else TickSize();
def bullBandAnchor = smoothTrailBasis - smoothTrailATR * (lowerMult + trailOuterATR);
def bearBandAnchor = smoothTrailBasis + smoothTrailATR * (upperMult + trailOuterATR);
def bullATRAnchor = low - safeSignalATR * signalATRMult;
def bearATRAnchor = high + safeSignalATR * signalATRMult;
def bullSignalAnchor = if signalAnchorMode == signalAnchorMode."ATR" then bullATRAnchor else bullBandAnchor;
def bearSignalAnchor = if signalAnchorMode == signalAnchorMode."ATR" then bearATRAnchor else bearBandAnchor;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# SINGLE TRADE ENGINE — NO PYRAMIDING
# tradeSide must be declared before newLong/newShort so [1] lookback resolves.
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
def tradeSide = CompoundValue(1,
if bullBreak and tradeSide[1] != 1 then 1
else if bearBreak and tradeSide[1] != -1 then -1
else tradeSide[1],
0);
def newLong = bullBreak and tradeSide[1] != 1;
def newShort = bearBreak and tradeSide[1] != -1;
def entryPrice = CompoundValue(1,
if newLong or newShort then close
else entryPrice[1],
Double.NaN);
def entryATRVal = CompoundValue(1,
if newLong or newShort then safeATR
else entryATRVal[1],
Double.NaN);
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# ATR TAKE PROFIT LEVELS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
def tradeDir = if tradeSide == 1 then 1.0 else -1.0;
def tpn2Level = if IsNaN(entryPrice) then Double.NaN else entryPrice + entryATRVal * tpn2Mult * tradeDir;
def tpn1Level = if IsNaN(entryPrice) then Double.NaN else entryPrice + entryATRVal * tpn1Mult * tradeDir;
def tp1Level = if IsNaN(entryPrice) then Double.NaN else entryPrice + entryATRVal * tp1Mult * tradeDir;
def tp2Level = if IsNaN(entryPrice) then Double.NaN else entryPrice + entryATRVal * tp2Mult * tradeDir;
def tp3Level = if IsNaN(entryPrice) then Double.NaN else entryPrice + entryATRVal * tp3Mult * tradeDir;
def tp4Level = if IsNaN(entryPrice) then Double.NaN else entryPrice + entryATRVal * tp4Mult * tradeDir;
def tp5Level = if IsNaN(entryPrice) then Double.NaN else entryPrice + entryATRVal * tp5Mult * tradeDir;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Take Profit STATE
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
def hit1 = if tradeSide == 1 then high >= tp1Level else low <= tp1Level;
def hit2 = if tradeSide == 1 then high >= tp2Level else low <= tp2Level;
def hit3 = if tradeSide == 1 then high >= tp3Level else low <= tp3Level;
def hit4 = if tradeSide == 1 then high >= tp4Level else low <= tp4Level;
def hit5 = if tradeSide == 1 then high >= tp5Level else low <= tp5Level;
def tp1Hit = CompoundValue(1,
if newLong or newShort then 0
else if tp1Hit[1] == 0 and hit1 then 1
else tp1Hit[1], 0);
def tp2Hit = CompoundValue(1,
if newLong or newShort then 0
else if tp2Hit[1] == 0 and hit2 then 1
else tp2Hit[1], 0);
def tp3Hit = CompoundValue(1,
if newLong or newShort then 0
else if tp3Hit[1] == 0 and hit3 then 1
else tp3Hit[1], 0);
def tp4Hit = CompoundValue(1,
if newLong or newShort then 0
else if tp4Hit[1] == 0 and hit4 then 1
else tp4Hit[1], 0);
def tp5Hit = CompoundValue(1,
if newLong or newShort then 0
else if tp5Hit[1] == 0 and hit5 then 1
else tp5Hit[1], 0);
def newTP1 = showATRTP and tp1Hit[1] == 0 and tp1Hit == 1 and !IsNaN(tp1Level);
def newTP2 = showATRTP and tp2Hit[1] == 0 and tp2Hit == 1 and !IsNaN(tp2Level);
def newTP3 = showATRTP and tp3Hit[1] == 0 and tp3Hit == 1 and !IsNaN(tp3Level);
def newTP4 = showATRTP and tp4Hit[1] == 0 and tp4Hit == 1 and !IsNaN(tp4Level);
def newTP5 = showATRTP and tp5Hit[1] == 0 and tp5Hit == 1 and !IsNaN(tp5Level);
def tpCount = tp1Hit + tp2Hit + tp3Hit + tp4Hit + tp5Hit;
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# OVERLAY — BANDS MODE
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot BandCenter = if overlayMode == overlayMode."Bands" then basis else Double.NaN;
BandCenter.SetLineWeight(3);
BandCenter.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
plot UpperBandPlot = if overlayMode == overlayMode."Bands" then upperBand else Double.NaN;
UpperBandPlot.SetLineWeight(1);
UpperBandPlot.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
plot LowerBandPlot = if overlayMode == overlayMode."Bands" then lowerBand else Double.NaN;
LowerBandPlot.SetLineWeight(1);
LowerBandPlot.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
plot UpperBandPlot2 = if overlayMode == overlayMode."Bands" then upperBand2 else Double.NaN;
UpperBandPlot2.SetLineWeight(1);
UpperBandPlot2.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
plot LowerBandPlot2 = if overlayMode == overlayMode."Bands" then lowerBand2 else Double.NaN;
LowerBandPlot2.SetLineWeight(1);
LowerBandPlot2.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
AddCloud(UpperBandPlot, UpperBandPlot2, GlobalColor("Bull"), GlobalColor("Bear"));
AddCloud(LowerBandPlot, LowerBandPlot2, GlobalColor("Bull"), GlobalColor("Bear"));
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# OVERLAY — CENTER MODE
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot CenterLine = if overlayMode == overlayMode."Center" then basis else Double.NaN;
CenterLine.SetLineWeight(3);
CenterLine.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
plot CenterPrice = if overlayMode == overlayMode."Center" then close else Double.NaN;
CenterPrice.SetDefaultColor(Color.CURRENT);
CenterPrice.Hide();
AddCloud(CenterLine, CenterPrice, GlobalColor("BullCloudFade"), GlobalColor("BearCloudFade"));
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# OVERLAY — TRAIL MODE
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot TrailInnerPlot = if overlayMode == overlayMode."Trail" then trailInner else Double.NaN;
TrailInnerPlot.SetLineWeight(1);
TrailInnerPlot.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
plot TrailOuterPlot = if overlayMode == overlayMode."Trail" then trailOuter else Double.NaN;
TrailOuterPlot.SetLineWeight(2);
TrailOuterPlot.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
AddCloud(TrailInnerPlot, TrailOuterPlot, GlobalColor("BullCloudFade"), GlobalColor("BearCloudFade"));
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# TREND CANDLES
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AssignPriceColor(
if !showCandles then Color.CURRENT
else if bullish then GlobalColor("Bull")
else GlobalColor("Bear")
);
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# ENTRY SIGNALS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AddChartBubble(showSignals and newLong, bullSignalAnchor, "Up", GlobalColor("Bull"), no);
AddChartBubble(showSignals and newShort, bearSignalAnchor, "Down", GlobalColor("Bear"), yes);
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# ENTRY & TARGET LEVEL LINES
# Each level plots continuously while the trade is active, producing a
# horizontal line from entry bar to the next signal. Dashes for targets.
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot EntryLine = if showATRTP and !IsNaN(entryPrice) then entryPrice else Double.NaN;
EntryLine.SetPaintingStrategy(PaintingStrategy.horizontal);
EntryLine.SetLineWeight(3);
EntryLine.AssignValueColor(if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
plot TPn2Line = if showATRTP and !IsNaN(tpn2Level) then tpn2Level else Double.NaN;
TPn2Line.SetPaintingStrategy(PaintingStrategy.DASHES);
TPn2Line.SetLineWeight(1);
TPn2Line.SetDefaultColor(color.red);
plot TPn1Line = if showATRTP and !IsNaN(tpn1Level) then tpn1Level else Double.NaN;
TPn1Line.SetPaintingStrategy(PaintingStrategy.DASHES);
TPn1Line.SetLineWeight(1);
TPn1Line.SetDefaultColor(color.dark_orange);
plot TP1Line = if showATRTP and !IsNaN(tp1Level) then tp1Level else Double.NaN;
TP1Line.SetPaintingStrategy(PaintingStrategy.DASHES);
TP1Line.SetLineWeight(1);
TP1Line.SetDefaultColor(color.yellow);
plot TP2Line = if showATRTP and !IsNaN(tp2Level) then tp2Level else Double.NaN;
TP2Line.SetPaintingStrategy(PaintingStrategy.DASHES);
TP2Line.SetLineWeight(1);
TP2Line.SetDefaultColor(color.yellow);
plot TP3Line = if showATRTP and !IsNaN(tp3Level) then tp3Level else Double.NaN;
TP3Line.SetPaintingStrategy(PaintingStrategy.DASHES);
TP3Line.SetLineWeight(1);
TP3Line.SetDefaultColor(color.green);
plot TP4Line = if showATRTP and !IsNaN(tp4Level) then tp4Level else Double.NaN;
TP4Line.SetPaintingStrategy(PaintingStrategy.DASHES);
TP4Line.SetLineWeight(1);
TP4Line.SetDefaultColor(color.green);
plot TP5Line = if showATRTP and !IsNaN(tp5Level) then tp5Level else Double.NaN;
TP5Line.SetPaintingStrategy(PaintingStrategy.DASHES);
TP5Line.SetLineWeight(1);
TP5Line.SetDefaultColor(GlobalColor("White"));
AddCloud(TP2Line, TP3Line, GlobalColor("yellow"), GlobalColor("yellow"));
AddCloud(TP3Line, TP4Line, color.dark_green, color.dark_green);
AddCloud(TP4Line, TP5Line, color.green, color.green);
AddCloud(TPn1Line, TPn2Line, color.magenta, color.magenta);
AddCloud(TPn1Line, EntryLine, color.dark_red, color.dark_red);
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# DASHBOARD LABELS
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AddLabel(showLabels,
if bullish then "Bull" else "Bear",
if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
AddLabel(showLabels,
"Trend: " + (if bullish then "UP" else "DOWN"),
if bullish then GlobalColor("Bull") else GlobalColor("Bear"));
AddLabel(showLabels,
"Entry: " + (if IsNaN(entryPrice) then "n/a" else AsText(Round(entryPrice, 2))),
GlobalColor("White"));
AddLabel(showLabels,
"TP: " +
(if tpCount == 0 then "0" else
if tpCount == 1 then "1" else
if tpCount == 2 then "2" else
if tpCount == 3 then "3" else
if tpCount == 4 then "4" else
"5"),
if bullish then GlobalColor("Bull") else GlobalColor("Bear"));