Jump to content

Ttm squeeze indicator for tradestation


robbye67

Recommended Posts

Hi robbye67;

 

I have two Indicators and one Strategy of Squeeze. I don´t know if this Squeeze is the indicator that you want.

 

Squeeze BB (Indicator), Easylenguage code:

 

 

 

{Bollinger Bands Squeeze indicator}

 

Inputs: {------------------------------------------------}

Price(Close),

Length(20), { Length for Average True Range (ATR) & Std. Deviation (SD) Calcs }

nK(1.5), { Keltner Channel ATRs from Average }

nBB(2), { Bollinger Band Std. Devs. from Average }

AlertLine( 1), { BBS_Index level at which to issue alerts }

NormalColor( Red), { Normal color for BBS_Ind }

AlertlColor( Green), { Color for BBS_Ind below alert line }

TrendHistAlert ( False );

 

Variables: {---------------------------------------------}

ATR(0), { Average True Range }

SDev(0), { Standard Deviation }

BBS_Ind(0), { Bollinger Band Squeeze Indicator }

alertTextID(-1),

Denom(0),

LHMult(0);

 

 

 

if ( barnumber=1 ) then

Begin

If minmove <> 0 then

LHMult = pricescale/minmove;

end;

 

if barnumber = 1 and alertTextID = -1 then

alertTextID = Text_New(date,time,0,"dummy");

 

{-- Calculate BB Squeeze Indicator ----------------------}

ATR = AvgTrueRange(Length);

SDev = StandardDev(Price, Length, 1);

 

Denom = (nK*ATR);

If Denom <> 0 then

BBS_Ind = (nBB * SDev) /Denom;

 

If BBS_Ind < Alertline then

SetPlotColor(1, NormalColor)

else

SetPlotColor(1, AlertlColor);

 

{-- Plot the Index & Alert Line -------------------------}

Plot1(0, "BBS_Ind");

 

{-- Plot delta of price from Donchian mid line ----------}

value2 = (LinearRegValue(price-((Highest(H, Length)+Lowest(L, Length))/2

+ xAverage(c,Length))/2,Length,0));

 

var:color(0); color = yellow;

 

if value2 > 0 then

if value2 > value2[1] then

color = Blue

else

color = RGB(0,0,80);

 

if value2 < 0 then

if value2 < value2[1] then color = Red

else

color = RGB(80,0,0);

 

Plot3(value2*LHMult, "Squeeze", color);

 

 

{-- Issue Alert when the Squeeze is On ------------------}

if BBS_Ind crosses below AlertLine

and Text_GetTime(alertTextID) <> time then

begin

text_setLocation(alertTextID, date, time, 0);

Alert("BB Squeeze Alert");

end;

 

{-- Issue Alert when the Squeeze Releases ---------------}

if BBS_Ind crosses above AlertLine

and Text_GetTime(alertTextID) <> time then

begin

text_setLocation(alertTextID, date, time, 0);

Alert("BB Squeeze Is Over");

end;

If TrendHistAlert then

begin

If value2>0 and value2[1]<0 then Alert ("Bullish Hist. Alert") ;

If value2<0 and value2[1]>0 then Alert ("Bearish Hist. Alert") ;

end;

 

Squeeze Indicator Easylenguage code:

 

 

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;

 

Squeeze Strategy LE-SE; Easylenguage code:

 

Inputs:

Price(Close),

Length(20), { Length for Average True Range (ATR) & Std. Deviation (SD) Calcs }

nK(1.5), { Keltner Channel ATRs from Average }

nBB(2), { Bollinger Band Std. Devs. from Average }

AlertLine( 1); { BBS_Index level at which to issue alerts }

 

Variables:

NickmNxtMove(0),

value2(0),

ATR(0), { Average True Range }

SDev(0), { Standard Deviation }

BBS_Ind(0), { Bollinger Band Squeeze Indicator }

Denom(0),

LHMult(0);

 

{-- Calculate BB Squeeze Entries and Exits ----------------------}

ATR = AvgTrueRange(Length);

SDev = StandardDev(Price, Length,alertline);

 

Denom = (nK*ATR);

If Denom <> 0 then

BBS_Ind = (nBB * SDev) /Denom;

 

value2 = (LinearRegValue(price-((Highest(H, Length)+Lowest(L, Length))/2

+ xAverage(c,Length))/2,Length,0));

 

Condition1 = value2 > 0;

Condition2 = value2 > value2[1];

 

Condition3 = value2 < 0;

Condition4 = value2 < value2[1];

 

if ( barnumber=1 ) then

Begin

If minmove <> 0 then

LHMult = pricescale/minmove;

end;

 

NickmNxtMove = value2*LHMult;

 

If {Condition1 and condition2 and }NickmNxtMove crosses above alertline then

Buy ("LE") next bar at market;

 

If {Condition3 and condition4 and }NickmNxtMove crosses below alertline then

Sellshort ("SE") next bar at market;

 

 

Of course, copy and paste the codes, and next compile.

Compiled in TS 9.1 and MCH 8.0.

Link to comment
Share on other sites

  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...