Ultimate Bullish Cross using Price Momentum and Volume For SwingTrading

Dap, Using this as upper may just have a great benefit. I have noticed so far that it does help with trend but the most impressive part is the MOVES when price goes through the average line. On a 2m TF, You can buy on the cross and have a very low risk stop out just above or below the avg line.
@METAL .. Happy New Year! .. glad you like the mod. I'm adding the squeeze dots to the "zeroline" to help identify the breakouts. I'll post it here when done.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Another modification: Added Mobius Squeeze V02 to the zeroline.

Ruby:
declare upper;

input Shortlength = 13; #hint Signal Fast Line
input LongLength = 50; #hint Slow Line
input price = close;

def agg = AggregationPeriod.DAY;
def PH_D = high(period = agg)[1];
def PL_D = low(period = agg)[1];
def PM_D1 = ((high(period = agg)[1] - low(period = agg)[1])/2) + low(period = agg)[1];
def PM_D2 = ((high(period = agg)[2] - low(period = agg)[2])/2) + low(period = agg)[2];
def ZeroAdd = if PM_D1 > PM_D2 then PL_D else PH_D;
addlabel(yes, "Daily", if PM_D1 > PM_D2 then Color.Cyan else Color.Red);

#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 = SimpleMovingAvg(PriceMomo, LongLength);

def VN = SimpleMovingAvg(volume, Shortlength);
def volumeMultiplier = (volume/VN);


plot Inertias = volumeMultiplier*PriceMomo+ZeroAdd;
plot avgInertia = ExpAvgMomoPrice+ZeroAdd;


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);

# 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 0 + ZeroAdd 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 0+ZeroAdd;
zeroline.SetPaintingStrategy(PaintingStrategy.DASHES);
zeroline.SetLineWeight(2);
zeroline.SetDefaultColor(Color.Green);
 

Attachments

  • VolumePriceMomentum2.jpg
    VolumePriceMomentum2.jpg
    166.4 KB · Views: 457
Last edited:
Another modification: Added Mobius Squeeze V02 to the zeroline.

Ruby:
declare upper;

input Shortlength = 13; #hint Signal Fast Line
input LongLength = 50; #hint Slow Line
input price = close;

def agg = AggregationPeriod.DAY;
def PH_D = high(period = agg)[1];
def PL_D = low(period = agg)[1];
def PM_D1 = ((high(period = agg)[1] - low(period = agg)[1])/2) + low(period = agg)[1];
def PM_D2 = ((high(period = agg)[2] - low(period = agg)[2])/2) + low(period = agg)[2];
def ZeroAdd = if PM_D1 > PM_D2 then PL_D else PH_D;
addlabel(yes, "Daily", if PM_D1 > PM_D2 then Color.Cyan else Color.Red);

#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 = SimpleMovingAvg(PriceMomo, LongLength);

def VN = SimpleMovingAvg(volume, Shortlength);
def volumeMultiplier = (volume/VN);


plot Inertias = volumeMultiplier*PriceMomo+ZeroAdd;
plot avgInertia = ExpAvgMomoPrice+ZeroAdd;


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);

# 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 0 + ZeroAdd 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 0+ZeroAdd;
zeroline.SetPaintingStrategy(PaintingStrategy.DASHES);
zeroline.SetLineWeight(2);
zeroline.SetDefaultColor(Color.Green);
@dap711 I tried modifying your code above to work as a lower study and wanted to rescale it. I gave it the good ol' college try but keep getting errors about an "invalid parameter at position 3...." which is where I call on the "normalizePlot" script....Any way you could look this over and help guide me in the right direction?
Thank you in advance
Code:
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----##
 
Last edited:
@dap711 I tried modifying your code above to work as a lower study and wanted to rescale it. I gave it the good ol' college try but keep getting errors about an "invalid parameter at position 3...." which is where I call on the "normalizePlot" script....Any way you could look this over and help guide me in the right direction?
Thank you in advance
Code:
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----##


The normalizePlot script accepts 3 parameters, but you are passing in 4.
 
@dap711 I tried modifying your code above to work as a lower study and wanted to rescale it. I gave it the good ol' college try but keep getting errors about an "invalid parameter at position 3...." which is where I call on the "normalizePlot" script....Any way you could look this over and help guide me in the right direction?
Thank you in advance
Code:
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----##

Try this for a lower study .. notice I changed the code for the "ZeroAdd":

Code:
declare lower;

input Shortlength = 13; #hint Signal Fast Line
input LongLength = 50; #hint Slow Line
input price = close;

def ZeroAdd = 0;

#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 = SimpleMovingAvg(PriceMomo, LongLength);

def VN = SimpleMovingAvg(volume, Shortlength);
def volumeMultiplier = (volume/VN);


plot Inertias = volumeMultiplier*PriceMomo+ZeroAdd;
plot avgInertia = ExpAvgMomoPrice+ZeroAdd;


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);

# 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 0 + ZeroAdd 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 0+ZeroAdd;
zeroline.SetPaintingStrategy(PaintingStrategy.DASHES);
zeroline.SetLineWeight(2);
zeroline.SetDefaultColor(Color.Green);
 
Is it possible to make this work with forex pairs on thinkorswim? That would be awesome
Volume in forex is the number of lots traded in a currency pair within a certain time period.
In other words, the amount of currency bought and sold.
But the ToS data feeds only track real Volume, which in the case of Forex doesn't exist.
So, it is not possible to utilize any volume indicators with Forex.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
273 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top