MOBIUS MOMENTUM SQUEEZE V02 dated 4/1/2020
Ruby:
# Momentum Squeeze V02
# Mobius
# V02.04.01.2020
# New faster Momentum Oscillator with outer band markers. New more accurate Squeeze indication.
declare lower;
input n = 20;
def c = close;
def mean = Inertia(c, n);
def SD = Sqrt((fold i = 0 to n
with s
do s + Sqr(mean - GetValue(c, i))) / n);
plot Momo = Inertia((c - mean) / SD, Floor(n ));
Momo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Momo.assignValueColor(if Momo > Momo[1] and Momo > 0
then Color.Cyan
else if Momo > 0 and Momo < Momo[1]
then Color.Blue
else if Momo < 0 and Momo < Momo[1]
then Color.dark_Red
else Color.Yellow);
def upper = mean + (2 * SD);
def lower = mean - (2 * SD);
def W = (upper - lower) / mean;
def B = Highest(W, n * 2);
def Sq = Lowest(W, n * 2);
plot Squeeze = if ((W - Sq) / (B - Sq)) <= .01
then 0
else Double.NaN;
Squeeze.SetStyle(Curve.POINTS);
Squeeze.SetLineWeight(3);
Squeeze.SetDefaultColor(Color.YELLOW);
AddLabel(Squeeze, "Squeeze", Color.YELLOW);
plot "0" = if !IsNaN(Squeeze) or IsNaN(c) then Double.NaN else 0;
"0".SetStyle(Curve.Points);
"0".SetDefaultColor(Color.GRAY);
plot "1" = if IsNaN(c) then Double.NaN else 1;
"1".SetDefaultColor(Color.GREEN);
plot "-1" = if IsNaN(c) then Double.NaN else -1;
"-1".SetDefaultColor(Color.dark_RED);
# End Code V02 Momentum Squeeze
@Jonas99 shared this on Discord. He provided this image with the comparison of the indicator which is the one on the very bottom.
Hi
@MerryDay or anyone else, can you explain how these original code variables map to this newer codes variables:
Original Code:
input length = 20; #hint length: Length for average calculation
input price = close;
input SDmult = 2.0;
input ATRmult = 1.5;
def K = (Highest(High, length) + Lowest(low, length)) /
2 + ExpAverage(close, length);
def SD = StDev(close, length);
def Avg = Average(close, length);
def ATR = Average(TrueRange(high, close, low), length);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);
plot Squeeze = if SDup < ATRup
Newer Code: My guesses of old code (some obvious):
input n = 20; length
def c = close; price
def mean = Inertia(c, n); Avg
def SD = Sqrt((fold i = 0 to n SD
with s
do s + Sqr(mean - GetValue(c, i))) / n);
def upper = mean + (2 * SD); ? SDup with SdMult = 2
def lower = mean - (2 * SD); ? SDlow - not in original code
def W = (upper - lower) / mean;
def B = Highest(W, n * 2); ? ATRup with ATRmult = 2 (if so why change from 1.5 to 2)
def Sq = Lowest(W, n * 2); ? ATRlow - not in orginal
plot Squeeze = if ((W - Sq) / (B - Sq)) <= .01 ? Why now less than 0.1 vs if SDup < ATRup
? why no K
? if any '?' are wrong, what are they and how do they map, and why the change?
Thanks!