inputs: Price(Close), BollingerPrice(Close), Length(20), NumDevsUp(2), NumDevsDn(-2), NumATRs(1.5), SQBreakoutColor(Blue), SQColor(Yellow), MLength(12), ColorNormLength( 14 ), UpColor( Green ), DnColor( Red ), GridForegroundColor( Black ), Displace(0); variables: ApplicationType( 0 ), Avg(0), Shift(0), SDev(0), KLowerBand(0), KUpperBand(0), BLowerBand(0), BUpperBand(0), Mom( 0 ), Accel( 0 ), LinReg( 0 ), ColorLevel( 0 ); { Bollinger Band Calculations } Avg = AverageFC( BollingerPrice, Length ) ; SDev = StandardDev( BollingerPrice, Length, 1 ) ; BUpperBand = Avg + NumDevsUp * SDev ; BLowerBand = Avg + NumDevsDn * SDev ; { Ketler Channel Calculations } Avg = AverageFC( Price, Length ) ; Shift = NumATRs * AvgTrueRange( Length ) ; KUpperBand = Avg + Shift ; KLowerBand = Avg - Shift ; { Now show me the Squeeze } Plot1[Displace](0, "Signal"); { If Bollinger bands are insize the ketler channel then alert, get ready for squeeze } if (BUpperBand <= KUpperBand and BLowerBand >= KLowerBand) then begin SetPlotColor(1, SQColor); end; { If you see this after the alert above then play the squeeze depending on the direction of momentum } if (BUpperBand > KUpperBand and BlowerBand < KLowerBand) then begin SetPlotColor(1, SQBreakoutColor); end; { Plot Momentum } if CurrentBar = 1 then ApplicationType = GetAppInfo( aiApplicationType ) ; LinReg = LinearRegValue(Price, Mlength, 0); // Smooth out the price, you can use close/high/low/average Mom = Momentum(LinReg, MLength); // Now get the momentum of the above value. Accel = Momentum(Mom, 1) ; { 1 bar acceleration } Plot2(Mom, "Momentum") ; { Gradient coloring } if CurrentBar > 1 and UpColor >= 0 and DnColor >= 0 then begin ColorLevel = NormGradientColor( Mom, true, ColorNormLength, UpColor, DnColor ) ; if ApplicationType = 1 then { study is applied to a chart } SetPlotColor(2, ColorLevel ) else if ApplicationType > 1 then { study is applied to grid app } begin SetPlotColor(2, GridForegroundColor) ; SetPlotBGColor(2, ColorLevel) ; end; end;