declare lower;
##----SCRIPT TO NORMALIZE PLOT----##
script normalizePlot {
input data = close;
input newRngMin = -100;
input newRngMax = 100;
def hhData = HighestAll( data );
def llData = LowestAll( data );
plot nr = ((( newRngMax - newRngMin ) * ( data - llData )) / ( hhData - llData )) + newRngMin;
}
script momoPrice {
input Shortlength = 13; #hint Signal Fast Line
input LongLength = 50; #hint Slow Line
input price = close;
#For Price Momentum
def PriceK = (Highest(high, Shortlength) + Lowest(low, Shortlength)) /
2 + ExpAverage(close, Shortlength);
def PriceKLong = (Highest(high, LongLength) + Lowest(low, LongLength)) /
2 + ExpAverage(close, LongLength);
def PriceMomo = Inertia(price - PriceK / 2, Shortlength);
def expAvgMomoPrice = ExpAverage(PriceMomo, LongLength);
def VN = SimpleMovingAvg(volume, Shortlength);
def volumeMultiplier = (volume / VN);
plot Inertias = volumeMultiplier * PriceMomo;
plot avgInertia = expAvgMomoPrice;
def avgBullishInertia = avgInertia > 0;
def avgBearishInertia = avgInertia < 0;
def bullishLongSignal = Inertias crosses above avgInertia and avgBullishInertia;
def bearishLongSignal = Inertias crosses below avgInertia and avgBullishInertia;
def longHoldSignal = Inertias > avgInertia and !(Inertias crosses above avgInertia) and avgBullishInertia;
def bearishPivotSignal = Inertias < bearishLongSignal and Inertias < 0 and avgBullishInertia;
def UncertainBullSignal = Inertias < bearishLongSignal and Inertias > 0 and avgBullishInertia;
def bullishShortSignal = Inertias crosses below avgInertia and avgBearishInertia;
def bearishShortSignal = Inertias crosses above avgInertia and avgBearishInertia;
def shortHoldSignal = Inertias < avgInertia and !(Inertias crosses below avgInertia) and avgBearishInertia;
def bullishPivotSignal = Inertias > bearishLongSignal and Inertias > 0 and avgBearishInertia;
def UncertainBearSignal = Inertias > bearishLongSignal and Inertias < 0 and avgBearishInertia;
AddLabel( avgBullishInertia, "Long Plays Only" , Color.CYAN);
AddLabel( bullishLongSignal, "Buy" , Color.GREEN);
AddLabel( bearishLongSignal, "Sell" , Color.RED);
AddLabel( longHoldSignal, "Hold Long" , Color.GREEN);
AddLabel(bearishPivotSignal, "Possible Bearish Pivot Point", Color.RED);
AddLabel(UncertainBullSignal, "Avoid Buys", Color.BLUE);
AddLabel( avgBearishInertia, "Short Plays Only", Color.DARK_RED);
AddLabel( bullishShortSignal, "Short", Color.GREEN);
AddLabel( bearishShortSignal, "Cover Short", Color.RED);
AddLabel( shortHoldSignal, "Hold Short", Color.GREEN);
AddLabel(bullishPivotSignal, "Possible Bullish Pivot Point", Color.GREEN);
AddLabel(UncertainBearSignal, "Avoid Shorts", Color.BLUE);
Inertias.DefineColor("Up", GetColor(1));
Inertias.DefineColor("Down", GetColor(0));
Inertias.AssignValueColor(if Inertias >= avgInertia then Inertias.Color("Up") else Inertias.Color("Down"));
avgInertia.SetDefaultColor(Color.RED);
}
script momoSqueeze {
# Momentum Squeeze V02
# Mobius
# V02.04.01.2020
# New faster Momentum Oscillator with outer band markers. New more accurate Squeeze indication.
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);
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 50 else Double.NaN;
Squeeze.SetPaintingStrategy(PaintingStrategy.DASHES);
Squeeze.SetLineWeight(2);
Squeeze.SetDefaultColor(Color.RED);
plot zeroline = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 50;
zeroline.SetPaintingStrategy(PaintingStrategy.DASHES);
zeroline.SetLineWeight(2);
zeroline.SetDefaultColor(Color.GREEN);
}
plot CrossA = normalizePlot(momoPrice(), momoSqueeze(), -100, 100);
##----END CODE----##