Amibroker AFL & Scanner | Candlestick Pattern Indicator

1100
Amibroker AFL and Scanner

CANDLESTICK PATTERN INDICATORS FOR AMIBROKER AFL

After testing many candlestick pattern indicators and having hands on experience with Amibroker AFL Code, we trailblazers, at Nifty trading academy got Indicators that were ranked by their ability to identify strong reversal patterns.

Amibroker AFL – Software for Technical Analysis

  • 1 ) Pattern identification Master

The Pattern identification Master indicator helps to Identified 10 popular candlestick patterns i.e. 5 of bullish and 5 of bearish patterns.

Each individual candlestick pattern can be turned on or off. The special alerts for each individual pattern can also be turned on or off. The pattern also can be set in a separate color for each different pattern.

Only this indicator will allow you to assign separate color to each candlestick pattern. This indicator uses different abbreviated labels which keeps the chart less cluttered and include onscreen legend to identify each pattern that is highlighted.

This indicator will not be able to identify morning or evening star patterns for some reason.  Also it seems to think with long wick that is a shooting star or hammer and regardless of how the large real body is.

It also doesn’t identify the hanging or inverted hammer candle.  The Candlestick patterns are ineffective if they are not traded within the proper circumstance of the market.

Nifty Trading Academy Candle Pattern

  • 2 ) Candle Patterns Indicator

The next candlestick pattern indicator for Amibroker is slightly better in terms of recognizing patterns even though it falls short in every other aspect.

The candle patterns indicator was designed to identify 30 different popular candlestick patterns. But unfortunately one cannot turn each individual candlestick pattern on or off. One can chose from strong reversals, continuations, unclassified and weak reversals patterns.

The Morning and Evening star patterns are identified by this candlestick pattern indicator, which is an improvement over the previous indicator. It can identify hanging and inverted hammer patterns more accurately.

[ Must Read : Intraday Trading Formula ]

This is the best indicator that we can recommend for recognizing candlestick patterns. We believe this is the best indicator for selecting patterns in Amibroker AFL.

Steve Nison is THE power on candlesticks. He is legally responsible for introducing Japanese candlestick trading to the Western world.

The Nison Candle Highlighter is designed in order to identify 28 candlestick patterns. They are according to Steve own specifications and know that the patterns are accurate. The highlighter has that ability to turn the individual candlestick pattern on or off. So, you should focus on the patterns that you are interested in trading.

The Nison Candle Highlighter improves accuracy in identifying candlestick patterns within the proper situation of the stock market. To conclude that’s the reason we the experts at nifty trading academy believes it is easily best candlestick pattern indicator for Amibroker AFL.

For more valuable Share Market Knowledge and our online courses check www.niftytradingacademy.net

—————————————————————————————————————————————————————————————–

 

Amibroker AFL & Scanner Code: 

// Nifty Trading Academy  - 0992561333

_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();
WhiteBody = C > O;
BigWhite = (Close – Open)/Open > 0.015 AND (Close – Open) * 2 > High – Low;
BlackBody = C < O;
BigBlack = (Open – Close)/Open > 0.015 AND (Open – Close) * 2 > High – Low;
Big = abs((Close – Open)/Open) > 0.014;
LongUpperShadow = H – Max(O,C) > (H – L)*0.67;
LongLowerShadow = Min(O,C) – L > (H – L)*0.67;
rng = abs((C-O)/O);
lowerShadow = Min(O,C) – L;
uppershadow = H – Max(O,C);
body = abs(O-C);
rngx = abs(H – L);
rngy = H-L;
shaven = lowerShadow < rngy*0.1;
ShavenBottom = L == Min(O,C);
ShavenHead = H == Max(O,C);
prevSize = abs(Ref(O,-1)-Ref(C,-1));
currentSize = abs(O-C);
fwh = Ref(H,-4);
fwl = Ref(L,-4);
isPrevLargeWhite = Ref(big,-1) AND Ref(whitebody,-1);
SmallRealBody = rng < 0.003 AND rng >0;
Diff = abs((prevSize – currentSize) / currentSize);
DownTrend = (H < Ref(H,-1) AND L < Ref(L,-1));
UpTrend = (H > Ref(H,-1) AND L > Ref(L,-1));
isPrevUpTrend = Ref(uptrend,-1);
RealBodyGapUp = Min(O,C) > Max(Ref(O,-1),Ref(C,-1));
RealBodyGapDown = Max(O,C) < Min(Ref(O,-1),Ref(C,-1));
FallingWindow = Ref(downtrend,-1) AND GapDown();
RisingWindow = Ref(uptrend,-1) AND GapUp();
isfalling = bigblack AND fallingwindow;
isrising = bigwhite AND risingwindow;
rwh = Ref(H,-4);
rwl = Ref(L,-4);
isFallingBlack = Ref(fallingwindow,-1) AND Ref(blackbody,-1);
horw = Ref(H,-2);
windowOpen = C < horw;
opensInside = O < Ref(O,-1) AND O > Ref(C,-1);
similarSize = diff <= 0.25;
GapUpFromWhite = realBodyGapUp AND isPrevLargeWhite AND isPrevUptrend;
isPrevLargeBlack = Ref(big,-1) AND Ref(blackbody,-1);
isPrevDownTrend = Ref(downtrend,-1);
GapDownFromBlack = realBodyGapDown AND isPrevLargeBlack AND isPrevDowntrend;
isRisingWhite = Ref(risingwindow,-1) AND Ref(whitebody,-1);
lorw = Ref(L,-2);
windowOpenx = C > lorw;
Doji = C == O AND V > 0;
LongLeggedDoji = doji AND (H – L)/L > 0.01;
StarUp = smallRealBody AND gapUpFromWhite;
DojiStarUp = doji AND gapUpFromWhite;
DojiStarDown = doji AND gapDownFromBlack;
StarDown = smallRealBody AND gapDownFromBlack;
isPrevDownTrendx = Ref(downtrend,-3);
firstDoji = Ref(doji,-2);
secDojiLower = Ref(doji,-1) AND Ref(realBodyGapDown,-1);
isPrevUpTrendx = Ref(uptrend,-3);
secDojiHigher = Ref(doji,-1) AND Ref(realBodyGapUp,-1);
BeltHold = shavenbottom AND shavenhead AND big;
Engulfing = Max(O,C) > Ref(Max(O,C),-1) AND Min(O,C) < Ref(Min(O,C),-1);
UmbrellaLine = uppershadow < rngx*0.1 AND lowershadow > body*2;
//====================================================================================================

//—————————————-
// Bearish
//—————————————-

// Kicker
KBR = Ref(O,-1) < Ref(C,-1) AND O <= Ref(O,-1) AND C <= O;

//Evening Doji Star
EveningDojiStar = Ref(dojiStarUp,-1) AND blackbody AND big AND C < Ref((O + C)/2,-2);
/*
A large white candlestick followed by a doji that gaps up from the
previous candles real body. This is followed by a third candlestick that is black and has a
close lower than the half way point of the first candlesticks real body. Must be preceeded by an uptrend.
*/

// Evening Star
EveningStar = Ref(starUp,-1) AND blackbody AND big AND C < Ref((O + C)/2,-2);
/*
A large white candlestick followed by a small real body of either colour that gaps up from the
previous candles real body. This is followed by a third candlestick that is black and has a
close lower than the half way point of the first candlesticks real body. Must be preceeded by an uptrend.
*/

// Grave Stone Doji
GraveStoneDoji = longleggeddoji AND L == C AND Ref(uptrend,-1);
/*
A doji with no lower shadow and an extremenly long upper shadow. Must be preceeded by an uptrend.
*/

//Bear 3 Formation
Bear3Formation = bigblack AND C < Ref(C,-4) AND
Ref(H,-1) <= fwh AND Ref(L,-1) >= fwl AND
Ref(H,-2) <= fwh AND Ref(L,-2) >= fwl AND
Ref(H,-3) <= fwh AND Ref(L,-3) >= fwl AND
Ref(isfalling, -4);
/*A strong black candle in a falling window, followed by three
candles that fall within the high/low range of the strong black candle, followed
by another strong black candle that closes below the close of the first black candle.
This is a bearish confirmation.*/

//Bearish Abandoned Baby
BearishAbandonedBaby = EveningDojiStar AND Ref(GapUp(),-1) AND GapDown();
/*
An evening doji star where there is a gap between the lower shadow of the doji and
the upper shadows of the prior and next candle.
*/

//Bearish Belt Hold
BearishBeltHold = belthold AND blackbody AND Ref(uptrend,-1);
/*
A large black candle with a shaven head and bottom preceeded by an uptrend.
*/

//Bearish Counter Attack
BearishCounterAttack = Ref(big AND whitebody,-1) AND O > Ref(H,-1) AND C == Ref(C,-1) AND big AND blackbody AND Ref(uptrend,-1);
/*
A large white candle followed by a black candle which opens sharply higher but closes
at the prior black candles close. Must be preceeded by an uptrend.
*/

// Bearish Harami Cross
BearishHaramiCross = doji AND Ref(C,-1) > O AND Ref(O,-1) < O AND Ref(big AND whitebody,-1) AND Ref(uptrend,-1);
/*
A doji preceded by and contained within the real body of a big white
candlestick in an uptrend
*/

// Bearish Harami
BearishHarami = Ref(big AND whitebody,-1) AND smallRealBody AND Min(O,C) > Ref(O,-1) AND Max(O,C) < Ref(C,-1) AND Ref(uptrend,-1);
/*
A small candlestick preceded by and whose real body is contained
within, the real body of a big white candlestick in an uptrend
*/

// Bearish Separating Line
BearishSeparatingLine = Ref(whitebody AND big,-1) AND blackbody AND big AND O == Ref(O,-1) AND Ref(downtrend,-1);
/*
A white candlestick followed by a black candlestick with the same opening price. Continues
the previous downtrend.
*/

// Dark Cloud Cover
DarkCloudCover = Ref(bigwhite,-1) AND blackbody AND O > Ref(H,-1) AND C <= Ref((O+C)/2,-1) AND C > Ref(O,-1) AND Ref(uptrend,-1);
/*
A strong white candle in an uptrend followed by a black candle that opens above the high of the
white candle and closes at least 50 percent into the white candles real body. Note that if the black candle completely
engulfs the white candles real body then this is not Dark Cloud Cover but a Bearish Engulfing Pattern.
*/
// Engulfing Bear
EngulfingBear = Ref(whitebody,-1) AND blackbody AND engulfing AND Ref(uptrend,-1);
/*
This bar is black and its real body engulfs the previous bars white real body. Must be preceeded by
an uptrend.
*/

//Hamging Man
HangingMan = umbrellaline AND uptrend AND Ref(uptrend,-1);
/*
The same as a hammer except must be preceeded by an uptrend.
*/

//Shooting Star
ShootingStar = smallRealBody AND shaven AND realBodyGapUp AND longuppershadow AND Ref(uptrend,-1);
/*
A small body that closes near the bottom of its range and
has a long upper shadow. There must be a real body gap up from the previous sessions candle. This
pattern occurs only after an uptrend.
*/

//Three Black Crows
ThreeBlackCrows = (big AND blackbody) AND Ref(big AND blackbody, -1) AND Ref(big AND blackbody, -2) AND O < Ref(O,-1) AND Ref(O,-1) < Ref(O,-2) AND Ref(uptrend,-4);
/*
The last three candlesticks are large and black. Each opens within or lower than the
previous candles real body.Must be preceeded by an uptrend.
*/

// Tri-Star Bottom
TriStarBottom = firstDoji AND secDojiLower AND doji AND realBodyGapUp AND isPrevDownTrendx;
/*
A doji followed by a lower doji which is followed by another doji that is higher than the
second doji. Must be preceeded by a downtrend.
*/

//Tweezer Tops
TweezerTops = H == Ref(H,-1) AND Ref(big AND whitebody,-1) AND Ref(uptrend,-2);
/* A large candle followed by a candle with the same high. Must be preceeded by an uptrend. */

// Upside Gap Two Crows
UpsideGapTwoCrows = Ref(big AND whitebody,-2) AND Ref(realBodyGapUp,-1) AND Ref(smallRealBody,-1) AND Ref(blackbody,-1) AND engulfing AND blackbody AND C > Ref((O+C)/2,-2) AND Ref(uptrend,-2);
/* A strong white candle followed by a small black candle which gaps above the previous
candles real body, followed by a black candle which engulfs the previous black candle. Preceeded by an uptrend. */

//—————————————-
// Bullish
//—————————————-

// Kicker
KBL = Ref(O,-1) > Ref(C,-1) AND O >= Ref(O,-1) AND C > O;

// Morning Star
MorningStar = Ref(starDown,-1) AND whitebody AND big AND C > Ref((O + C)/2,-2);
/*
A large black candlestick followed by a small real body of either colour,
that gaps below the previous black candles real body, with a third white candlestick, that has a close
higher than the half way point of the first black candlestick. Must be preceeded by a downtrend.
*/

// Morning Doji Star
MorningDojiStar = Ref(dojiStarDown,-1) AND whitebody AND big AND C > Ref((O + C)/2,-2);
/*
A large black candlestick followed by a doji that gaps below its real body, with a third
white candlestick, that has a close at least half of the way up the black candlestick. Must be preceeded by a
downtrend.
*/

// Bull 3 Formation
Bull3Formation = bigwhite AND C > Ref(C,-4) AND
Ref(H,-1) <= rwh AND Ref(L,-1) >= rwl AND
Ref(H,-2) <= rwh AND Ref(L,-2) >= rwl AND
Ref(H,-3) <= rwh AND Ref(L,-3) >= rwl AND
Ref(isrising, -4);
/*
A strong white candle in a rising window, followed by three
candles that fall within the high/low range of the strong white candle, followed
by another strong white candle that closes above the close of the first white candle.
This is confirmation of the Bullish trend.”
*/

// Bullish Abandoned Baby
BullishAbandonedBaby = morningdojistar AND Ref(GapDown(),-1) AND GapUp();
/*
A morning doji star where there is a gap between the lower shadow of the doji and
the prior and next candle.
*/
// Bullish Belt Hold
BullishBeltHold = belthold AND whitebody AND Ref(downtrend,-1);
/*
A large white candle with no upper or lower shadow preceeded by a downtrend.
*/

// Bullish Counter Attack
BullishCounterAttack = Ref(big AND blackbody,-1) AND O < Ref(H,-1) AND C == Ref(C,-1) AND big AND whitebody AND Ref(downtrend,-1);
/*
A large black candle followed by a white candle which opens sharply lower but closes at the
prior white candles close. Must be preceeded by a downtrend
*/

// Bullish Harami Cross
BullishHaramiCross = doji AND Ref(O,-1) > O AND Ref(C,-1) < O AND Ref(big AND blackbody,-1) AND Ref(downtrend,-1);
/*
A doji preceded by and contained within the real body of a big
black candlestick in a downtrend.
*/

// Bullish Harami
BullishHarami = Ref(big AND blackbody,-1) AND smallRealBody AND Min(O,C) > Ref(C,-1) AND Max(O,C) < Ref(O,-1) AND Ref(downtrend,-1);
/*
A small candlestick, preceded by, and whose body is contained within a big black
candlestick in a downtrend
*/

// Bullish Separating Line
BullishSeparatingLine = Ref(blackbody AND big,-1) AND whitebody AND big AND O == Ref(O,-1) AND Ref(uptrend,-1);
/*
A black candlestick followed by a white candlestick with the same opening price. Continues
the previous uptrend.
*/

//Dragonfly Doji
DragonflyDoji = longleggeddoji AND H==C AND Ref(downtrend,-1);
/*A doji with no upper shadow AND a long lower shadow preceeded by a downtrend.*/

// Engulfing Bull
EngulfingBull = Ref(blackbody,-1) AND whitebody AND engulfing AND Ref(downtrend,-1);
/*
This bar is white and its real body engulfs the previous bars black real body. Must be
preceeded by a downtrend.
*/

// Hammer
Hammer = umbrellaline AND Ref(downtrend,-1);
/*
The upper shadow is less than ten percent of the range
and the lower shadow is more than two times the size of the body. Must be preceeded by a downtrend.
*/

//Inverted Hammer
InvertedHammer = smallRealBody AND shaven AND realBodyGapDown AND longuppershadow AND Ref(downtrend,-1);
/*
An upside down Hammer that appears after a downtrend
*/

//Piercing Line
PiercingLine = Ref(bigblack,-1) AND whitebody AND O < Ref(L,-1) AND C >= Ref((O+C)/2,-1) AND C < Ref(O,-1) AND Ref(downtrend,-1);
/*
A stong black candle followed by a white candle that opens below the low of
the prior black candle but closes more than halfway into the black candles real body. Preceeded by a downtrend. Note that if the
white candle engulfs the prior black candles real body then this is a Bullish Engulfing Pattern not a Piercing Pattern
*/

// SeperatingLines
SeperatingLines = O == Ref(O,-1) AND (blackbody AND Ref(whitebody,-1) OR whitebody AND Ref(blackbody,-1));
/*
a black candlestick is followed by a white candlestick, or a white with a black,and they have the same opening prices.
*/

//Three White Soldiers
ThreeWhiteSoldiers = (whitebody AND big) AND Ref(whitebody AND big,-1) AND Ref(whitebody AND big,-2) AND O > Ref(O,-1) AND Ref(O,-1) > Ref(O,-2);
/*
The last three candlesticks are large and white. Each opens within or higher than the
previous candles real body.
*/

// Tri-Star Top
TriStarTop = firstDoji AND secDojiHigher AND doji AND realBodyGapDown AND isPrevUpTrendx;
/*
A doji followed by a higher doji which is followed by another doji that is lower than the
second doji. Must be preceeded by an uptrend.
*/

// Tweezer Bottoms
TweezerBottoms = L == Ref(L,-1) AND Ref(big AND blackbody,-1) AND Ref(downtrend,-2);
/* A large candle followed by a candle with the same Low. Must be preceeded by a downtrend. */
//—————————————-
// Continuation
//—————————————-

// Downward Gapping Tasuki
DownwardGappingTasuki = isFallingBlack AND whitebody AND opensInside AND C > Ref(O,-1) AND windowOpen AND similarSize;
/* A black candle that gaps down followed by a similarly sized white candle that opens Inside the black candles real body AND closes above it. */

//Upward Gapping Tasuki
UpwardGappingTasuki = isRisingWhite AND blackbody AND opensInside AND C < Ref(O,-1) AND windowOpenx AND similarSize;
/* A white candle that gaps up followed by a similarly sized black candle that opens Inside the white candles real body AND closes below it; */

//Inverted Black Hammer
InvertedBlackHammer = blackbody AND InvertedHammer;

STS = /*Bears*/
WriteIf(KBR, “Bearish Kicker”,
WriteIf(EveningDojiStar, “Evening Doji Star”,
WriteIf(EveningStar, “Evening Star”,
WriteIf(GraveStoneDoji, “Grave Stone Doji”,
WriteIf(Bear3Formation, “Bear 3 Formation”,
WriteIf(BearishAbandonedBaby, “Bearish Abandoned Baby”,
WriteIf(BearishBeltHold, “Bearish Belt Hold”,
WriteIf(BearishCounterAttack, “Bearish Counter Attack”,
WriteIf(BearishHaramiCross, “Bearish Harami Cross”,
WriteIf(BearishHarami, “Bearish Harami”,
WriteIf(BearishSeparatingLine, “BearishSeparatingLine”,
WriteIf(DarkCloudCover, “DarkCloudCover”,
WriteIf(EngulfingBear, “Engulfing Bear”,
WriteIf(HangingMan, “Hanging Man”,
WriteIf(ShootingStar, “Shooting Star”,
WriteIf(ThreeBlackCrows, “Three Black Crows”,
WriteIf(TriStarBottom, “TriStar Bottom”,
WriteIf(TweezerTops, “Tweezer Tops”,
WriteIf(UpsideGapTwoCrows, “UpsideGapTwoCrows”,
/*Bulls*/
WriteIf(KBL, “Bullish Kicker”,
WriteIf(MorningStar, “Morning Star”,
WriteIf(MorningDojiStar, “Morning Doji Star”,
WriteIf(Bull3Formation, “Bull 3 Formation”,
WriteIf(BullishAbandonedBaby, “Bullish Abandoned Baby”,
WriteIf(BullishBeltHold, “Bullish Belt Hold”,
WriteIf(BullishCounterAttack, “Bullish Counter Attack”,
WriteIf(BullishHaramiCross, “Bullish Harami Cross”,
WriteIf(BullishHarami, “Bullish Harami”,
WriteIf(BullishSeparatingLine, “Bullish Separating Line”,
WriteIf(DragonflyDoji, “Dragonfly Doji”,
WriteIf(EngulfingBull, “Engulfing Bull”,
WriteIf(Hammer, “Hammer”,
WriteIf(InvertedHammer, “Inverted Hammer”,
WriteIf(PiercingLine, “Piercing Line”,
WriteIf(SeperatingLines, “Seperating Lines”,
WriteIf(ThreeWhiteSoldiers, “Three White Soldiers”,
WriteIf(TriStarTop, “Tri-Star Top”,
WriteIf(TweezerBottoms, “Tweezer Bottoms”,””))))))))))))))))))))))))))))))))))))));

Filter = 1;

Col = IIf(KBR OR EveningDojiStar OR EveningStar OR GraveStoneDoji OR Bear3Formation OR BearishAbandonedBaby
OR BearishBeltHold OR BearishCounterAttack OR BearishHaramiCross OR BearishHarami OR BearishSeparatingLine
OR DarkCloudCover OR EngulfingBear OR HangingMan OR ShootingStar OR ThreeBlackCrows OR TriStarBottom
OR TweezerTops OR UpsideGapTwoCrows, colorRed, IIf( MorningStar OR MorningDojiStar OR Bull3Formation
OR BullishAbandonedBaby OR BullishBeltHold OR BullishCounterAttack OR BullishHaramiCross
OR BullishHarami OR BullishSeparatingLine OR DragonflyDoji OR EngulfingBull OR Hammer OR InvertedHammer
OR PiercingLine OR SeperatingLines OR ThreeWhiteSoldiers OR TriStarTop OR TweezerBottoms OR KBL, colorGreen, 0));
AddColumn(C, “Close”, 1.2);
AddTextColumn(sts, “Candle”, 1.0, Col, colorDefault,100);