I used the standard momentum histogram colors, CYAN, BLUE, RED, YELLOW... Modify for your needs...
Ruby:
# Momentum_Label
# Displays a Label to display current momentum
# Coded by rad14733 for usethinkscript.com
# v1.0 : 2021-08-11 : Initial release
# SETTINGS
input price = close;
input length = 20;
# MOMENTUM LOGIC
def K = (Highest(high, length) + Lowest(low, length)) / 2 + ExpAverage(close, length);
def momo = Inertia(price - K / 2, length);
def pos = momo >= 0;
def neg = momo < 0;
def up = momo >= momo[1];
def dn = momo < momo[1];
def posUp = pos and up;
def posDn = pos and dn;
def negDn = neg and dn;
def negUp = neg and up;
# DISPLAY LABEL
AddLabel(yes,
if posUp then "Pos+Up"
else if posDn then "Pos+Dn"
else if negDn then "Neg+Dn"
else if negUp then "Neg+Up"
else "",
if posUp then Color.CYAN
else if posDn then Color.BLUE
else if negDn then Color.RED
else if negUp then Color.YELLOW
else Color.CURRENT
);
# END - Momentum_Label
Last edited by a moderator: