EXPLORE stocks trading in a Band

#1
Hello

Can someone pls help me to correct the foll AFL

********************************************************
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorBlueGrey ), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram ), 2 );
_SECTION_END();

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();

Sq1=Close/BBandTop(C,20,2) < 1 AND Close/BBandBot(C,20,2) < 1;
Sq2=Ref(C,-2)/Ref(BBandTop(C,20,2),-2) <1 AND Ref(C,-2)/Ref(BBandBot(C,20,2),-2) <1;
Sq3=Ref(C,-3)/Ref(BBandTop(C,20,2),-3) <1 AND Ref(C,-3)/Ref(BBandBot(C,20,2),-3) <1;
//if (Sq1Cond1=sq1 AND sq2 == True) AND (Sq1Cond2=sq2 AND sq3 == True), AddColumn(

Sq1Cond1=sq1 AND sq2 == True;
Sq1Cond2=sq2 AND sq3 == True;
Filter=Sq1Cond1 AND Sq1Cond2;

SetOption("NoDefaultColumns", True );
AddColumn( DateTime(), "Date", formatDateTime );
AddTextColumn( FullName(), "Full name", 77 , colorDefault, IIf( (Sq1Cond1 AND Sq1Cond2 == True), colorLightBlue, colorDefault ) );
*********************************************************

I'm looking for (in Explore O/p window)
1)List of stocks which satisfy close / BBTop <1 and close/BBott < 1 -> O/p as "Squeeze"
AND
2)List of stock which satisfy close / BBTop >1 and close/BBott > 1 -> O/p as "Squeeze Breakout"

Looking back 3 - 5 candles

Thanking you in advance

Rbhapkar
 

KelvinHand

Well-Known Member
#3
Someone........PLS HELP ......:confused:
Try the Bollingerband Width and see whether suit your need

Code:
bbw= (BBandTop(C, 20)-BBandBot(C, 20))/MA( C,20 ) ;
Plot(bbw,"BB Width", colorBlue); 
Plot(0.05, "", colorBlack, styleDashed);

Buy=1;
Sell=1;

//look back past 5 bars, but at least 3 bars must had bbw<0.05 
Filter = Sum(Bbw<0.05 AND H!=L ,5)>=3 AND V>1000;

SetOption("NoDefaultColumns", True );
AddColumn( DateTime(), "Date", formatDateTime );
AddTextColumn( FullName(), "Full name", 77 , colorDefault,colorDefault );
AddColumn(b, "BBW", 1.4);
The other method to look for bbsqueeze is to look into TTM Squeeze where interception of Bollinger band and KeltnerBand
 
Last edited:

Similar threads