JustUncleL

Price Action Doji Harami v0.2 by JustUncleL

This is an updated and final version of this indicator. This version distinguishes between the true Harami and the other Doji candlestick patterns as used with the Heikin Ashi candle charts. These candle patterns indicate a potential trend reversal or pullback.
The patterns identified are:
- Bearish Harami (Red Highlight above Bar):
One to three (default 3) large body Bull (green) candles followed by a small (red)
or no body candle (less than 0.5pip) with wicks top and bottom that are at least 60% of candle.
- Bullish Harami (Green Highlight below Bar):
One to three (default 3) large body Bear (red) candles followed by a small (green)
or no body candle (less than 0.5pip) with wicks top and bottom that are at least 60% of candle.
- Bearish Doji (Fuchsia Highlight above Bar):
One to three (default 3) large body Bull (green) candles followed by a small (green)
with wicks top and bottom that are at least 60% of candle.
- Bullish Doji (Aqua Highlight below Bar):
One to three (default 3) large body Bear (red) candles followed by a small (red)
with wicks top and bottom that are at least 60% of candle.

You can optionally specify how large the candles prior to Harami/Doji are in pips, default is 0 pip.
If you set this to zero then it will have no candle size consideration. You can also specify how many look back candles (1-3) are used in Harami/Doji calculations (default 3).

Included option to perform Calculations purely on Heikin Ashi candles, this helps when you want to see the HA Doji/Harami bars with the normal candle stick chart.

Also can optionally set an alert condition for when Harami/Doji found, this also displays a circle on the bottom of the screen when alert is triggered.
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
//
// Name: Price Action Doji Harami v0.2 by JustUncleL
// By: JustUncleL
// Date: 4-Sep-2016
// Version: v0.2
//
// Description:
//   Identifies the Harami + Doji candlestick patterns as used with the
//   Heikin Ashi candles. These candles indicates a potential trend reversal.
//   The patterns identified are:
//   - Bearish Harami (Red Highlight above Bar): 
//       Three(3) large body Bull (green) candles followed by a small (red) 
//       or no body candle with wicks top and bottom that are at least 60% of candle.
//   - Bullish Harami (Green Highlight below Bar): 
//       Three(3) large body Bear (red) candles followed by a small (green) 
//       or no body candle with wicks top and bottom that are at least 60% of candle.
//   - Bearish Doji (Fuchsia Highlight above Bar): 
//       Three(3) large body Bull (green) candles followed by a small (green) 
//       with wicks top and bottom that are at least 60% of candle.
//   - Bullish Doji (Aqua Highlight below Bar): 
//       Three(3) large body Bear (red) candles followed by a small (red)
//       with wicks top and bottom that are at least 60% of candle.
//
//   You can optionally specify large candle in pips previous to Doji, default is 1 pip.
//   If you set this to zero then it will have no candle size consideration.
//   Included option to perform Calculations purely on Heikin Ashi candles, this helps
//   when you want to still see the HA Doji/Harami with the normal candle chart.
//
// references:
//  - Price Action Candles v0.3 by JustUncleL
//  
// modifications:
//  0.2 Modified Doji caculations to seperate true Harami patterns. 
//      Included option to show/alert all Doji's patterns.
//      Included option to Calculate Doji/Harami patterns only on Heikin Ashi candles.
//      Included option to specify how many candles (1 to 3) to look back to test Doji/Harami pattern.
//  0.1 Original Beta version.
//
study(title = "Price Action Doji Harami v0.2 by JustUncleL", shorttitle="PACDOJI v0.2 by JustUncleL", overlay = true, max_bars_back=3000)
//

pctDw = input(60,minval=0,maxval=90,title="Doji, Min % of Range of Candle for Wicks")
pipMin= input(0,minval=0,title="Doji, Previous Candle Min Pip Body Size")
sname=input(true,title="Show Price Action Bar Names")
cbar = input(false,title="Highlight Harami & Doji Bars")
sHm    = input(false,title="Show Only Harami Style Doji's")
setalm = input(true, title="Generate Alert for Harami & Doji Bars")
uha   =input(true, title="Use Heikin Ashi Candles for Calculations")
bars = input(3,minval=1,maxval=3,step=1,type=integer, title="Doji, Number of Lookback Bars")
//
// Use only Heikinashi Candles for all calculations
srcclose = uha ? security(heikinashi(tickerid), period, close) : close
srcopen = uha ? security(heikinashi(tickerid), period, open) : open
srchigh = uha ? security(heikinashi(tickerid), period, high) : high
srclow = uha ?security(heikinashi(tickerid), period, low) : low

//
pip = syminfo.mintick
range = srchigh - srclow


// Calculate Doji/Harami Candles
pctCDw = (pctDw/2) * 0.01
pctCDb = (100-pctDw) * 0.01

//Lookback Candles for bulls or bears
lbBull = bars==1? srcopen[1]>srcclose[1]: bars==2? (srcopen[1]>srcclose[1] and srcopen[2]>srcclose[2]): bars==3?(srcopen[1]>srcclose[1] and srcopen[2]>srcclose[2] and srcopen[3]>srcclose[3]):false
lbBear = bars==1? srcopen[1]<srcclose[1]: bars==2? (srcopen[1]<srcclose[1] and srcopen[2]<srcclose[2]): bars==3?(srcopen[1]<srcclose[1] and srcopen[2]<srcclose[2] and srcopen[3]<srcclose[3]):false

//Lookback Candle Size only if mininum size is > 0
lbSize = pipMin==0? true : bars==1 ? (abs(srcopen[1]-srcclose[1])>pipMin*pip) :
  bars==2 ? (abs(srcopen[1]-srcclose[1])>pipMin*pip and abs(srcopen[2]-srcclose[2])>pipMin*pip) :
  bars==3 ? (abs(srcopen[1]-srcclose[1])>pipMin*pip and abs(srcopen[2]-srcclose[2])>pipMin*pip and abs(srcopen[3]-srcclose[3])>pipMin*pip) :
  false

dojiBu = (srcopen[1] >= max(srcclose,srcopen) and srcclose[1]<=min(srcclose,srcopen)) and lbSize and
  (abs(srcclose-srcopen)<range*pctCDb and (srchigh-max(srcclose,srcopen))>(pctCDw*range) and (min(srcclose,srcopen)-srclow)>(pctCDw*range))? 1 : 0

dojiBe = (srcclose[1] >= max(srcclose,srcopen) and srcopen[1]<=min(srcclose,srcopen)) and lbSize and
  (abs(srcclose-srcopen)<range*pctCDb and (srchigh-max(srcclose,srcopen))>(pctCDw*range) and (min(srcclose,srcopen)-srclow)>(pctCDw*range))? 1 : 0
  
haramiBull = (srcopen<=srcclose or (max(srcclose,srcopen)-min(srcclose,srcopen))<pip*0.5) and lbBull and dojiBu
haramiBear = (srcopen>=srcclose or (max(srcclose,srcopen)-min(srcclose,srcopen))<pip*0.5) and lbBear and dojiBe

dojiBull = not sHm and not haramiBull and not haramiBear and lbBull and dojiBu
dojiBear = not sHm and not haramiBull and not haramiBear and lbBear and dojiBe

//
plotshape(haramiBear and sname?srchigh:na,title="Bearish Harami",text='Bearish\nHarami',color=red, style=shape.arrowdown,location=location.abovebar)
plotshape(haramiBear and cbar?max(srcopen,srcclose):na,title="Bear Colour Harami",color=red, style=shape.circle,location=location.absolute,size=size.normal)
//
plotshape(haramiBull and sname?srclow:na,title="Bullish Harami",text='Bullish\nHarami',color=green, style=shape.arrowup,location=location.belowbar)
plotshape(haramiBull and cbar?max(srcopen,srcclose):na,title="Bull Colour Harami",color=green, style=shape.circle,location=location.absolute,size=size.normal)
//
plotshape(dojiBear and sname?srchigh:na,title="Bearish Doji",text='Bearish\nDoji',color=fuchsia, style=shape.arrowdown,location=location.abovebar)
plotshape(dojiBear and cbar?max(srcopen,srcclose):na,title="Bear Colour Doji",color=fuchsia, style=shape.circle,location=location.absolute,size=size.normal)
//
plotshape(dojiBull and sname?srclow:na,title="Bullish Doji",text='Bullish\nDoji',color=aqua, style=shape.arrowup,location=location.belowbar)
plotshape(dojiBull and cbar?max(srcopen,srcclose):na,title="Bull Colour Doji",color=aqua, style=shape.circle,location=location.absolute,size=size.normal)

// Only Alert harami Doji's
bcolor = haramiBull ? 1 : haramiBear ? 2 : dojiBull ? 3 : dojiBear ? 4 : 0
baralert = setalm and bcolor>0
alertcondition(baralert,title="PACDOJI Alert",message="PACDOJI Alert")

//
plotshape(na(baralert[1])?na:baralert[1], transp=0,style=shape.circle,location=location.bottom, offset=-1,title="Bar Alert Confirmed", 
  color=bcolor[1]==1 ? green : bcolor[1]==2? red : bcolor[1]==3? aqua : bcolor[1]==4? fuchsia : na)

//EOF
pls give permisson to use it sir
Reply
JustUncleL PRO Kumaran1964
@Kumaran1964, Not required, this is open unsecured script.
Reply
jason0027 JustUncleL
@JustUncleL, can i use this indicator on mt4?
Reply
@jason0027, Pinescript is not compatible with MT4.
Reply
Thanks.
Very interestingly. I will try.
Reply
clap habds for you.. this script has become an important in my stategy
Reply
@ElderFx, You are welcome.
Reply
thank you looks good i will test it and maybe make an ea if its proftable
Reply
This indicator is not a strategy by itself. Need to add to a strategy like 6EMA strategy, or add it to another Heikin Ashi strategy to show potential price action points.
Reply
You are genuinely a legend my friend - I've said it before: I love your work. Thanks. You seem to think like me, but I just simply can't do what you do. I'm grateful.
Reply
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
Malaysia
日本
한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing Priority Support Ideas Published Followers Following Private Messages Chat Sign Out