bollingerband with candlestick patterns

#1
candlestick patterns with bollinger band :thumb::thumb:

// Author Abnash Singh @ [email protected]
// pattern logic obtained from Candlesticker.com
// Other references Candle Master

_SECTION_BEGIN("MetaCandle");
BgColor=ParamColor("BgColor", colorBlack);
SetChartBkGradientFill( BgColor,BgColor,BgColor);
upcolor=ParamColor("Up color ",colorGreen);
downcolor=ParamColor("Down color ",colorRed);
barcolor=IIf(C>Ref(C,-1),upcolor,downcolor);
Insidecolor=IIf(C<O,barcolor,BgColor);
SetBarFillColor(Insidecolor);
PlotOHLC( Open, High, Low, Close, " " , barcolor, styleCandle | styleThick );
_SECTION_END();

_SECTION_BEGIN("trend with pivot levels");
uptrend= Signal(29)<MACD(13);
downtrend= Signal(29)>MACD(13);
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();


_SECTION_BEGIN("Magnified Market Price");

FS=Param("Font Size",28,11,100,1);
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );

Hor=Param("Horizontal Position",766,1,1200,1);
Ver=Param("Vertical Position",1,1,1,1);
GfxTextOut(""+C,Hor , Ver );
GfxTextOut( Name(), Hor,Ver-50 );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorRed) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );

_SECTION_END();

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






// 2 bar Gann Trend Swing Chart
// Developed by Abnash Singh
// Contact me at [email protected] * .co.uk
// Parameters allow you to choose bar/candle type and color intensity.
// And display of Bollinger band
//trend line beg
SetBarsRequired(1000);
BarLum1 = Param("Bar Color Intensity", 8, 0, 10,01);
UpBarColor = ColorBlend(ColorRGB(5,36,5), ColorRGB(10,75,10), BarLum1);
DnBarColor = ColorBlend(ColorRGB(36,5,5), ColorRGB(75,10,10), BarLum1);
BarColor = IIf(Close > Open, UpBarColor, DnBarColor);
SetBarFillColor(BarColor);
stylecndl=ParamList("Bar or Candle chart?","Bar|Candle");
Showboll=ParamList("Show Bollinger Bands","Yes|No");

if (stylecndl=="Bar")stylec=styleBar;
else stylec=styleCandle;

Plot(C,"close",colorWhite,stylec);
tline=tlinebs=barhi=barlo=beglo=beghi=endi=begi=0;
for (i=1;i<BarCount;i++)
{

if (i>=4)
{
//if (i>begi+1)PlotText(WriteVal(I>begi+1,1.0),i,H+15,colorOrange);


if (H>H[i-1]AND H[i-1]>H[i-2] AND i>beglo)
{
tline=H;
barhi=1;
barlo=0;
prevhi=beghi;
beghi=i;
}
if (L<L[i-1]AND L[i-1]<L[i-2] AND i>beghi)
{
tline=L;
barlo=1;
barhi=0;
prevlo=beglo;
beglo=i;
}
}


if (i==beglo)
{
if (prevlo>beghi)
{
begi=prevlo; begval=L[prevlo];
endi=beglo;endval=L[beglo];
}
else if (beghi>prevlo)
{
begi=beghi; begval=H[beghi];
endi=beglo;endval=L[beglo];
}
}
if (i==beghi)
{
if (prevhi>beglo)
{
begi=prevhi; begval=H[prevhi];
endi=beghi;endval=H[beghi];
}
else if (beglo>prevhi)
{
begi=beglo; begval=L[beglo];
endi=beghi;endval=H[beghi];
}
}

if (endi-begi>1)
{
incr=(endval-begval)/(endi-begi);
for (j=begi;j<=endi;j++)
{
tline[j]=begval+(j-begi)*incr;
}
}

if (tline==0)tline=Null;
//trend line end
}
tline=IIf(tline>0,tline,Null);
Plot(tline,"Trendline",colorWhite,styleLine);

if (showboll=="Yes")
{
_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();


_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
}
















_SECTION_BEGIN("Magnified Market Price");

FS=Param("Font Size",28,11,100,1);
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );

Hor=Param("Horizontal Position",766,1,1200,1);
Ver=Param("Vertical Position",1,1,1,1);
GfxTextOut(""+C,Hor , Ver );
GfxTextOut( Name(), Hor,Ver-50 );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorRed) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );

_SECTION_END();

_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("Pattern Recognition");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
showpatterns=ParamList("Show Patterns","No|Yes");
ind=0;
O1 = Ref(O,-1);O2 = Ref(O,-2);O3 = Ref(O,-3);O4 = Ref(O,-4);
H1 = Ref(H,-1);H2 = Ref(H,-2);H3 = Ref(H,-3);H4 = Ref(H,-4);
L1 = Ref(L,-1);L2 = Ref(L,-2);L3 = Ref(L,-3);L4 = Ref(L,-4);
C1 = Ref(C,-1);C2 = Ref(C,-2);C3 = Ref(C,-3);C4 = Ref(C,-4);
MA13=MA(C,15);MA134=Ref(MA(C,15),-4);
Plot(MA13,"MA13",colorBlue,styleNoTitle);
m=0;n=0;Dayx=0;z=0;
if (showpatterns=="Yes")
{
for (i=1;i<BarCount-1;i++)
{
if (i>2)
{
//bearish doji evening star
if (C2>O2
AND((C2-O2)/(.001+H2-L2)>.6)
AND (C2<O1)
// AND (C1>=O1)
AND ((H1-L1)>(3*(abs(C1-O1))))
AND (O>C) AND (O<O1)
AND MA13-MA134>0)
{
m=i;ind=1;
PlotText("BEARDJEV*",i,H+10,colorRed);
}
//abandoned baby
if (((C1 == O1)
AND (C2>O2) AND ((C2-O2)/(.001+H2-L2)>.6)
AND (O>C)
AND (L1>H2)
AND (L1>H))
AND MA13-MA134>0)
{
m=i;ind=1;
PlotText("ABBABY",i,H+10,colorRed);
}
//Bearish Kicking
if(C<O AND ((O-C)/(.001+H-L)>.6)
AND (C-L<0.2*(H-L)) AND (H-O<0.2*(H-L))
AND C1>O1 AND ((C1-O1)/(.001+H1-L1)>.6)
AND (H1-C1<0.2*(H-L)) AND (O1-L1<0.2*(H-L))
AND O<O1 )
{
m=i;ind=1;
PlotText("BearKik",i,H+10,colorRed);
}

//Dark Cloud Cover
if(C1>O1 AND (C1-O1)/(.001+H1-L1)>.6
AND (O>C)
AND (O>=H1) AND (C>O1)
AND (((C1+O1)/2)>C)
AND (C>O1)
AND MA13-MA134>0)
{
m=i;ind=1;
PlotText("DRKCLD",i,H+10,colorRed);
}

//Three black crows
if (C<O AND ((O-C)/(.001+H-L)>.6)
AND C1<O1 AND ((O1-C1)/(.001+H1-L1)>.6)
AND C2<O2 AND ((O2-C2)/(.001+H2-L2)>.6)
AND (C<C1) AND (C1<C2) AND (O>C1)
AND (O<O1) AND (O1>C2) AND (O1<O2)
AND (((C-L)/(H-L))<.2)
AND (((C1-L1)/(H1-L1))<.2)
AND (((C2-L2)/(H2-L2))<.2)
AND MA13-MA134>0 )
{
m=i;ind=1;
PlotText("3BLKCROWS",i,H+10,colorRed);
}
//3 Inside down
if ((C2>O2) AND ((C2-O2)/(.001+H2-L2)>.6)
AND (O1>C1)
AND (O1<= C2) AND (O2<= C1)
AND ((O1-C1)<(C2-O2))
AND (O>C)
AND (C<C1) AND (O<O1)
AND MA13-MA134>0 )
{
m=i;ind=1;
PlotText("3INSIDEDN",i,H+10,colorRed);
}

//3 Outside down
if (((C2>O2)
AND (O1>C1) AND ((O1-C1)/(.001+H1-L1)>.6)
AND (O1>= C2) AND (O2>= C1)
AND ((O1-C1)>(C2-O2))
AND (O>C) AND (C<C1))
AND MA13-MA134>0 )
{
m=i;ind=1;
PlotText("3OUTSIDEDN",i,H+10,colorRed);
}






//Bearish upside gap two crows
if (O>C AND O1>C1
AND C1>C AND O1<O AND (O1-C1<O-C)
AND (C>C2)
AND O1>C2 AND C2>O2
AND ((c2-o2)/(.001+H2-L2)>.6)
AND MA13-MA134>0 )
{
m=i;ind=1;
PlotText("UPSDGAP2CRW",i,H+10,colorRed);
}
//bullish Patterns
//Piercing line
if (((C1<O1) AND ((C2-o2)/(.001+H2-L2)>.6)
AND (((O1+C1)/2)<C) AND (O<C) AND (O<C1) AND (C<O1) AND
((C-O)/(.001+(H-L))>0.6))
AND MA13-MA134<0 )
{
n=i;ind=1;
PlotText("PrcingLin",i,L-10,colorGreen);
}

//Bullish Kicking
if(C>O AND ((C-O)/(.001+H-L)>.6)
AND (H-C<0.2*(H-L)) AND (O-L<0.2*(H-L))
AND C1<O1 AND ((o1-c1)/(.001+H1-L1)>.6)
AND (H1-O1<0.2*(H1-L1)) AND (C1-L1<0.2*(H1-L1))
AND O>o1 )
{
n=i;ind=1;
PlotText("BullKik",i,L-10,colorGreen);
}
//Bullish Abandoned Baby
if ((C1 == O1)
AND (O2>C2) AND ((O2-C2)/(.001+H2-L2)>.6)
AND (C>O)
AND (L2>H1)
AND (L>H1)
AND MA13-MA134<0)
{
n=i;ind=1;
PlotText("BullABBABY",i,L-10,colorGreen);
}



if (m==i-1 AND (O>=(C-0.1*(H-L)) OR (O<c1 OR C>C1)))PlotText("PC",i,H+2,colorWhite);
else if (m==i-1 )PlotText("Ignore",i,H+2,colorRed);
if (n==i-1 AND (O<=(C+0.1*(H-L)) OR (O>c1 OR C>C1)))PlotText("PC",i,L-2,colorWhite);
else if (n==i-1 )PlotText("Ignore",i,L-2,colorRed);
//Bullish Morning doji Star
if ((O2>C2)
AND ((O2-C2)/(.001+H2-L2)>.6)
AND (C2>O1)
// AND (O1>C1)
AND ((H1-L1)>(3*(abs(C1-O1))))
AND (C>O)
AND (O>O1)
AND MA13-MA134<0)
{
n=i;ind=1;
PlotText("BullMornD*",i,L-10,colorGreen);
}
//3 Inside up
if ((O2>C2) AND ((O2-c2)/(.001+H2-L2)>.6)
AND (C1>O1)
AND (C1<= O2)
AND (C2<= O1)
AND ((C1-O1)<(O2-C2))
AND (C>O)
AND (C>C1) AND (O>O1)
AND MA13-MA134<0)

{
n=i;ind=1;
PlotText("3InsideUp",i,L-10,colorGreen);
}
//3 Outside up
if ((O2>C2) AND ((O2-c2)/(.001+H2-L2)>.6)
AND (C1>O1)
AND (C1>= O2)
AND (C2>= O1)
AND ((C1-O1)>(O2-C2))
AND (C>O)
AND (C>C1)
AND MA13-MA134<0)
{
n=i;ind=1;
PlotText("3OutsideUp",i,L-10,colorGreen);
}
//3 White soldiers
if ((C>O) AND ((C-O)/(.001+H-L)>.6)
AND (C1>O1) AND ((C-O)/(.001+H-L)>.6)
AND (C2>O2) AND ((C-O)/(.001+H-L)>.6)
AND (C>C1) AND (C1>C2) AND (O<C1)
AND (O>O1) AND (O1<C2) AND (O1>O2)
AND (((H-C)/(H-L))<.2)
AND (((H1-C1)/(H1-L1))<.2)
AND (((H2-C2)/(H2-L2))<.2)
AND MA13-MA134<0 )
{
n=i;ind=1;
PlotText("3WhtSoldiers",i,L-10,colorGreen);
}
//Bullish Concealing Baby Swallow
if (O>C AND O1>C1 AND O2>C2 AND O3>C3
AND (H==O AND L==C) AND
(H2==O2 AND L2==C2) AND
(H3==O3 AND L3==C3)
AND ((O3-C3)/(.001+H3-L3)>.6)
AND ((O2-C2)/(.001+H2-L2)>.6)
AND (((H1-L1)>3*(O1-C1)) AND
((H1-C1)/(.001+H1-L1)>0.6) AND
((H1-O1)/(.001+H1-L1)>0.6))
AND (O2<O3 AND C2<C3 AND O1<C2)
AND (H1< O AND L1>C))
{
n=i;ind=1;
PlotText("ConcBABYSWL",i,L-10,colorGreen);
}
//moderate reversal indicators
//Bullish Dragonfly Doji
if (O==C AND H==C
AND ((H-L)/(.001+H-L)>.6)
AND MA13-MA134<0 )
{
n=i;ind=1;
PlotText("BullDoji",i,L-10,colorGreen);
}
// bullish long legged Doji
if (abs(O-C)<0.15*(H-L)
AND abs(O-(H+L)/2)<0.2*(H-L)
AND C<C1 AND C1<C2 AND C2<C3 )
{
n=i;ind=1;
PlotText("BullLLDoji",i,L-10,colorGreen);
}
//Gravestone Doji
if (L==O AND L==C
AND ((H-L)/(.001+H-L)>.6)
AND O1<C1 AND ((H1-L1)/(.001+H1-L1)>.6)
AND (C1-C)<0.2*(H-L))


{
n=i;ind=1;
PlotText("GRaveStnDoji!!!",i,L-10,colorGreen);
}
//Doji Star
if (O==C AND O1==C1 AND O2[1]==C2
AND O1<C2 AND O1<C
AND MA13-MA134<0 )
{
n=i;ind=1;
PlotText("Doji*",i,L-10,colorGreen);
}
//Bullish Mat Hold
if (C4>O4 AND ((C4-O4)/(.001+H4-L4)>.6)
AND (C3>C4) AND O3>C3 AND H3-L3>3*(O3-C3)
AND (C2<C3 OR O2<C3) AND H2-L2>3*abs((O2-C2))
AND (C1<C2 OR C1<O2) AND O1>C1 AND H1-L1>3*(O1-C1)
AND (H>H3) AND C>O AND ((C-O)/(.001+H-L)>.6))
{
n=i;ind=1;
PlotText("BullMathold",i,L-10,colorGreen);
}



}

}

}
Pattern="Morning Star";
Title = Date()+" "+ Interval(format=2)+" "+Name()+" O "+WriteVal(O,1.2)+" H "+WriteVal(H,1.2)+" L "+WriteVal(L,1.2)+" C "+WriteVal(C,1.2)+" "+EncodeColor(colorYellow)+" MA13/MA134 "+WriteVal(MA13,1.2)+"/"+WriteVal(MA134,1.2)+
"\n"+EncodeColor(colorRed)+" ";
 
#3
hi

Which are most powerful candle patterns?
pattern explorer system defined this years ago.

BE MDS PL HAMMER DOJI
BULLISH ENGULFING MORNING STAR PIERCING LINE

DCC EDS BLE SS
DARK CLOUD COVER EVENING STAR BEARISH ENGULFING SHOOTING STAR
 
#5
Hi arjun,
Is it possible in the afl to have a signal of arrow or box to show in the chart of the begning and ending of the pattern.It will be easy to take action after the complition of the pattern for a layman.

Regards
Debashish
 

Similar threads

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?