input enableAllAlerts = YES; declare lower; def nBB = 2.0; def Length = 20.0; def nK_High = 1.0; def nK_Mid = 1.5; def nK_Low = 2.0; def price = close; def momentum = TTM_Squeeze(price = price, length = length, nk = nk_Mid, nbb = nbb)."Histogram"; plot oscillator = momentum; def BolKelDelta_Mid = reference BollingerBands("num_dev_up" = nBB, "length" = Length )."upperband" - KeltnerChannels("factor" = nK_Mid, "length" = Length)."Upper_Band"; def BolKelDelta_Low = reference BollingerBands("num_dev_up" = nBB, "length" = Length )."upperband" - KeltnerChannels("factor" = nK_Low, "length" = Length)."Upper_Band"; def BolKelDelta_High = reference BollingerBands("num_dev_up" = nBB, "length" = Length )."upperband" - KeltnerChannels("factor" = nK_High, "length" = Length)."Upper_Band"; oscillator.DefineColor("Up", CreateColor(0, 255, 255)); oscillator.DefineColor("UpDecreasing", CreateColor(0, 0, 255)); oscillator.DefineColor("Down", CreateColor(255, 0, 0)); oscillator.DefineColor("DownDecreasing", CreateColor(255, 255, 0)); oscillator.AssignValueColor( if oscillator[1] < oscillator then if oscillator[0] >= 0 then oscillator.Color("Up") else oscillator.Color("DownDecreasing") else if oscillator >= 0 then oscillator.Color("UpDecreasing") else oscillator.Color("Down") ); oscillator.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); oscillator.SetLineWeight(5); plot squeeze = If(IsNaN(close), Double.NaN, 0); squeeze.DefineColor("NoSqueeze", Color.GREEN); squeeze.DefineColor("SqueezeLow", Color.black); squeeze.DefineColor("SqueezeMid", Color.RED); squeeze.DefineColor("SqueezeHigh", Color.orange); squeeze.AssignValueColor(if BolKelDelta_High <= 0 then squeeze.Color("SqueezeHigh") else if BolKelDelta_Mid <= 0 then squeeze.Color("SqueezeMid") else if BolKelDelta_Low <= 0 then squeeze.Color("SqueezeLow") else squeeze.color("noSqueeze")); squeeze.SetPaintingStrategy(PaintingStrategy.POINTS); squeeze.SetLineWeight(3); def enteredHighSqueeze = BolKelDelta_High <= 0 and BolKelDelta_High[1] > 0; def enteredMidSqueeze = BolKelDelta_Mid <= 0 and BolKelDelta_Mid[1] > 0; def enteredLowSqueeze = BolKelDelta_Low <= 0 and BolKelDelta_Low[1] > 0; def exitedHighSqueeze = BolKelDelta_High > 0 and BolKelDelta_High[1] <= 0; def exitedMidSqueeze = BolKelDelta_Mid > 0 and BolKelDelta_Mid[1] <= 0; def exitedLowSqueeze = BolKelDelta_Low > 0 and BolKelDelta_Low[1] <= 0; alert(enteredHighSqueeze and enableAllAlerts, "Entered High Squeeze", alert.bar, sound.NoSound); alert(enteredMidSqueeze and enableAllAlerts, "Entered Mid Squeeze", alert.bar, sound.NoSound); alert(enteredLowSqueeze and enableAllAlerts, "Entered Low Squeeze", alert.bar, sound.NoSound); alert(exitedHighSqueeze and enableAllAlerts, "High Squeeze Fired", alert.bar, sound.NoSound); alert(exitedMidSqueeze and enableAllAlerts, "Mid Squeeze Fired", alert.bar, sound.NoSound); alert(exitedLowSqueeze and enableAllAlerts, "Low Squeeze Fired", alert.bar, sound.NoSound);