Inspired by the Greek River Lethe along the banks of forgetfulness and obscurity, price impulses gently fade, restoring balance and harmony like equilibrium. A toggled buy (Y/N) indicator using shaded areas divergence engines enhance leading strategies.
Code:
#===========================================
# LETHE EFFECT — HARMONY OSCILLATOR v2.02
# ATR-Normalized • Divergence Engine • Strategy Mode
# Adeodatus/cbt / 31/12/25
#===========================================
declare lower;
#------------------------- INPUTS -------------------------
input length = 14;
input decay_factor = 0.85;
input overBought = 70;
input overSold = 30;
input midLevel = 50;
input enableStrategy = no;
input divergenceLookback = 5;
#-------------------- MOMENTUM + FADE ---------------------
def momentum = close - close[length];
rec faded = if BarNumber() == 1
then momentum
else faded[1] * decay_factor + momentum * (1 - decay_factor);
#----------------------- NORMALIZATION ---------------------
def ATRnorm = Max(ATR(length), AbsValue(momentum));
def LetheValue = if ATRnorm != 0
then (faded / ATRnorm * 50) + 50
else 50;
#------------------------- PLOTS ---------------------------
plot Lethe = LetheValue;
Lethe.SetDefaultColor(Color.CYAN);
Lethe.SetLineWeight(3);
plot MidLine = midLevel;
MidLine.SetDefaultColor(Color.WHITE);
MidLine.SetStyle(Curve.LONG_DASH);
plot OB = overBought;
OB.SetDefaultColor(Color.RED);
OB.SetStyle(Curve.SHORT_DASH);
plot OS = overSold;
OS.SetDefaultColor(Color.PLUM);
OS.SetStyle(Curve.SHORT_DASH);
# Correct cloud ordering
AddCloud(OB, Lethe, Color.DARK_RED, Color.DARK_RED);
AddCloud(Lethe, OS, Color.DARK_GRAY, Color.DARK_GRAY);
#----------------------- SIGNALS ---------------------------
def buySignal = Crosses(Lethe, OS, CrossingDirection.ABOVE);
def sellSignal = Crosses(Lethe, OB, CrossingDirection.BELOW);
plot BuyArrow = if buySignal then OS else Double.NaN;
BuyArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BuyArrow.SetDefaultColor(Color.GREEN);
BuyArrow.SetLineWeight(4);
plot SellArrow = if sellSignal then OB else Double.NaN;
SellArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SellArrow.SetDefaultColor(Color.RED);
SellArrow.SetLineWeight(4);
#------------------- DIVERGENCE ENGINE ---------------------
def priceLow = low == Lowest(low, divergenceLookback);
def letheLow = Lethe == Lowest(Lethe, divergenceLookback);
def priceHigh = high == Highest(high, divergenceLookback);
def letheHigh = Lethe == Highest(Lethe, divergenceLookback);
def isBullDiv = priceLow and !letheLow; # bullish divergence
def isBearDiv = priceHigh and !letheHigh; # bearish divergence
plot BullDivMark = if isBullDiv then Lethe else Double.NaN;
BullDivMark.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BullDivMark.SetDefaultColor(Color.GREEN);
plot BearDivMark = if isBearDiv then Lethe else Double.NaN;
BearDivMark.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
BearDivMark.SetDefaultColor(Color.RED);
#------------------------- LABELS ---------------------------
AddLabel(
yes,
"Lethe Harmony: " + Round(Lethe, 1),
if Lethe > OB then Color.RED
else if Lethe < OS then Color.PLUM
else if AbsValue(Lethe - midLevel) < 5 then Color.WHITE
else Color.GRAY
);
Last edited by a moderator: