The Price Memory Trend conversion was taken from this original code.
https://www.tradingview.com/script/1CDVWIFi-Uptrick-Price-Memory-Trend/
Bubbles and candle color can be turned on/off in the settings.
Price Memory Trend is a custom indicator designed to detect directional shifts and volatility changes using a non-traditional price memory approach. Unlike moving average systems, it builds a dynamic memory of price that adapts gradually over time, allowing it to detect significant deviations and trend transitions with reduced noise.
https://www.tradingview.com/script/1CDVWIFi-Uptrick-Price-Memory-Trend/
Bubbles and candle color can be turned on/off in the settings.
Price Memory Trend is a custom indicator designed to detect directional shifts and volatility changes using a non-traditional price memory approach. Unlike moving average systems, it builds a dynamic memory of price that adapts gradually over time, allowing it to detect significant deviations and trend transitions with reduced noise.
Code:
#Price_Memory_Trend
#Converted by Chewie 1/24/2026
#Original Code: https://www.tradingview.com/script/1CDVWIFi-Uptrick-Price-Memory-Trend/
declare upper;
# =========================
# INPUTS
# =========================
input colorbar = yes;
input bubble = yes;
input memoryStrength = 0.12;
input memoryDecay = 0.96;
input devLen = 50;
input bandMult = 1.6;
input atrLength = 50;
input atrMult = 1.3;
# =========================
# COLORS
# =========================
DefineGlobalColor("Bull", CreateColor(0, 255, 170));
DefineGlobalColor("Bear", CreateColor(255, 0, 255));
DefineGlobalColor("Neutral", Color.GRAY);
# =========================
# PRICE MEMORY
# =========================
def price = close;
rec memory =
if BarNumber() == 1 then price
else memory[1] + (price - memory[1]) * memoryStrength;
def base = memory * memoryDecay + price * (1 - memoryDecay);
# =========================
# ADAPTIVE DEVIATION
# =========================
def dev = AbsValue(price - base);
def avgDev = ExpAverage(dev, devLen);
def rawUpper = base + avgDev * bandMult;
def rawLower = base - avgDev * bandMult;
# =========================
# TREND STATE
# =========================
def bullCond = price crosses above rawUpper;
def bearCond = price crosses below rawLower;
rec trendState =
if BarNumber() == 1 then 0
else if bullCond then 1
else if bearCond then -1
else trendState[1];
def newBull = bullCond and trendState[1] != 1;
def newBear = bearCond and trendState[1] != -1;
# =========================
# TRAILING CORE BANDS
# =========================
rec trailLower =
if BarNumber() == 1 then rawLower
else if trendState == 1 then Max(rawLower, trailLower[1])
else rawLower;
rec trailUpper =
if BarNumber() == 1 then rawUpper
else if trendState == -1 then Min(rawUpper, trailUpper[1])
else rawUpper;
# =========================
# ACTIVE CORE BANDS (MASKED)
# =========================
def bullCore = if trendState == 1 then trailLower else Double.NaN;
def bearCore = if trendState == -1 then trailUpper else Double.NaN;
# =========================
# ATR OUTER BANDS
# =========================
def atr = Average(TrueRange(high, close, low), atrLength);
def bullOuter = if trendState == 1 then bullCore - atr * atrMult else Double.NaN;
def bearOuter = if trendState == -1 then bearCore + atr * atrMult else Double.NaN;
# =========================
# CLOUD SERIES (NO RECS HERE)
# =========================
def bullCloudTop = bullCore;
def bullCloudBot = bullOuter;
def bearCloudTop = bearOuter;
def bearCloudBot = bearCore;
# =========================
# PLOTS
# =========================
plot BullCorePlot = bullCore;
BullCorePlot.SetDefaultColor(GlobalColor("Bull"));
BullCorePlot.SetLineWeight(3);
plot BearCorePlot = bearCore;
BearCorePlot.SetDefaultColor(GlobalColor("Bear"));
BearCorePlot.SetLineWeight(3);
plot BullATRPlot = bullOuter;
BullATRPlot.SetDefaultColor(GlobalColor("Bull"));
#BullATRPlot.SetStyle(Curve.SHORT_DASH);
plot BearATRPlot = bearOuter;
BearATRPlot.SetDefaultColor(GlobalColor("Bear"));
#BearATRPlot.SetStyle(Curve.SHORT_DASH);
# =========================
# CLOUDS (FINALLY LEGAL)
# =========================
AddCloud(bullCloudTop, bullCloudBot,
GlobalColor("Bull"), GlobalColor("Bull"));
AddCloud(bearCloudTop, bearCloudBot,
GlobalColor("Bear"), GlobalColor("Bear"));
# =========================
# UP / DOWN MARKERS
# =========================
AddChartBubble(bubble and newBull, low, "Up", GlobalColor("Bull"), no);
AddChartBubble(bubble and newBear, high, "Down", GlobalColor("Bear"), yes);
# =========================
# STATUS LABEL
# =========================
AddLabel(
yes,
if trendState == 1 then "PMT: BULL"
else if trendState == -1 then "PMT: BEAR"
else "PMT: NEUTRAL",
if trendState == 1 then GlobalColor("Bull")
else if trendState == -1 then GlobalColor("Bear")
else GlobalColor("Neutral")
);
def bull = trendState == 1;
def bear = trendState == -1;
AssignPriceColor(if !colorbar then Color.CURRENT else if bull then GlobalColor("Bull") else if bear then GlobalColor("Bear") else Color.GRAY);
Last edited: