Candlestick patterns recognition

v10.3
Candlestick patterns recognition

This indicator recognize about 13 candlestick patterns and draw their names with green and red arrows on chart:

  • Doji
  • Evening star
  • Morning star
  • Shooting star
  • Hammer
  • Inverted hammer
  • Bearish harami
  • Bullish harami
  • Bearish engulfing
  • Bullish engulfing
  • Piercing line
  • Hanging man
  • Dark cloud cover

I know a lot of people are looking for codes for candlestick pattern recognition, I stumble upon this pinescript code at TV so I decided to convert it to prorealtime.

The patterns tests are stored into "data" variables, so these codes snippets can be taken to make other indicators, trading strategies or screeners with ease.

Text colour can be changed with the R.G.B. values at the beginning of the code.

//text color
// white = 255,255,255 ; black = 0,0,0
r = 255
g = 255
b = 255

atr = averagetruerange[10](close)*0.5

DojiSize = 0.05
data=(abs(open - close) <= (high - low) * DojiSize)
if data then
 DRAWTEXT("Doji", barindex, high+atr, Dialog, Standard, 12) COLOURED(R,G,B)
endif

data2=(close[2] > open[2] and min(open[1], close[1]) > close[2] and open < min(open[1], close[1]) and close < open )
if data2 then
 DRAWTEXT("Evening Star", barindex, high[1]+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)
 DRAWARROWDOWN(barindex-1,high[1]) COLOURED(255,0,10)
endif

data3=(close[2] < open[2] and max(open[1], close[1]) < close[2] and open > max(open[1], close[1]) and close > open )
if data3 then
 DRAWTEXT("Morning Star", barindex, low[1]-atr*1.5, Dialog, Standard, 12) COLOURED(0,255,10)
 DRAWARROWUP(barindex-1,low[1]) COLOURED(0,255,10)
endif

data4=(open[1] < close[1] and open > close[1] and high - max(open, close) >= abs(open - close) * 3 and min(close, open) - low <= abs(open - close))
if data4 then
 DRAWTEXT("Shooting Star", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)
 DRAWARROWDOWN(barindex,high) COLOURED(255,0,10)
endif

data5=(((high - low)>3*(open -close)) and  ((close - low)/(.001 + high - low) > 0.6) and ((open - low)/(.001 + high - low) > 0.6))
if data5 then
 DRAWTEXT("Hammer", barindex, high+atr, Dialog, Standard, 12) COLOURED(R,G,B)
endif

data5b=(((high - low)>3*(open -close)) and  ((high - close)/(.001 + high - low) > 0.6) and ((high - open)/(.001 + high - low) > 0.6))
if data5b then
 DRAWTEXT("Inverted Hammer", barindex, high+atr, Dialog, Standard, 12) COLOURED(R,G,B)
endif

data6=(close[1] > open[1] and open > close and open <= close[1] and open[1] <= close and open - close < close[1] - open[1] )
if data6 then
 DRAWTEXT("Bearish Harami", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)
 DRAWARROWDOWN(barindex,high) COLOURED(255,0,10)
endif

data7=(open[1] > close[1] and close > open and close <= open[1] and close[1] <= open and close - open < open[1] - close[1] )
if data7 then
 DRAWTEXT("Bullish Harami", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,255,10)
 DRAWARROWUP(barindex,low) COLOURED(0,255,10)
endif

data8=(close[1] > open[1] and open > close and open >= close[1] and open[1] >= close and open - close > close[1] - open[1] )
if data8 then
 DRAWTEXT("Bearish Engulfing", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)
 DRAWARROWDOWN(barindex,high) COLOURED(255,0,10)
endif

data9=(open[1] > close[1] and close > open and close >= open[1] and close[1] >= open and close - open > open[1] - close[1] )
if data9 then
 DRAWTEXT("Bullish Engulfing", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,255,10)
 DRAWARROWUP(barindex,low) COLOURED(0,255,10)
endif

data10=(close[1] < open[1] and  open < low[1] and close > close[1] + ((open[1] - close[1])/2) and close < open[1])
if data10 then
 DRAWTEXT("Piercing Line", barindex, low-atr*1.5, Dialog, Standard, 12) COLOURED(0,255,10)
 DRAWARROWUP(barindex,low) COLOURED(0,255,10)
endif

data14=(((high-low>4*(open-close))and((close-low)/(.001+high-low)>=0.75)and((open-low)/(.001+high-low)>=0.75)) and high[1] < open and high[2] < open)
if data14 then
 DRAWTEXT("Hanging Man", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)
 DRAWARROWDOWN(barindex,high) COLOURED(255,0,10)
endif

data15=((close[1]>open[1])and(((close[1]+open[1])/2)>close)and(open>close)and(open>close[1])and(close>open[1])and((open-close)/(.001+(high-low))>0.6))
if data15 then
 DRAWTEXT("Dark Cloud Cover", barindex, high+atr*1.5, Dialog, Standard, 12) COLOURED(255,0,10)
 DRAWARROWDOWN(barindex,high) COLOURED(255,0,10)
endif

RETURN

 

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

  1. AleX • 183 days ago #

    Bug on 10.2? 
    Errore di sintassi: Linea 12, carattere 9
    Uno dei seguenti caratteri sarebbe più appropriato di “(“:
    – “,”
    – “=”

    • Nicolas • 183 days ago #

      This indicator is only compatible with version 10.3, because it draws graphical components.

  2. AleX • 183 days ago #

    Ok, i’m waiting for release. Thanks for this sharing, very very interesting. 

  3. Doctrading • 183 days ago #

    Nice work !

  4. Pierre • 182 days ago #

    Very nice !

    This has been requested many times by PRT users.

  5. Sofitech • 168 days ago #

    Bonjour Nicolas. Superbe indicateur. Peut-on l’utiliser pour des stratégies ? Visiblement oui mais dans le module backtest, je ne vois apparaître que le nom de l’indicateur lorsque j’essaye de saisir des conditions d’achat / vente …Comme faire ?
    J’ai la même question avec le Fractal ZigZag, seul le nom de l’indicateur apparaît. 

    Merci pour tes lumières. Cette version semble très prometteuse.

    • Nicolas • 168 days ago #

      En effet, puisque tu remarques que la fonction RETURN ne retourne rien comme variable. Dans la version 10.3 on peut se permettre de le faire lorsque on souhaite juste faire des indications graphiques.

      Pour utiliser ces patterns dans ton code, il te suffit juste de faire des copier/coller des lignes “data” et de les vérifier comme des conditions banales : IF DATA14>0 THEN ..

  6. Sofitech • 168 days ago #

    ok merci. Je vais tester cela…

  7. Ashevs21 • 166 days ago #

    how do i get version 10.3??

  8. Pascal • 159 days ago #

    Ça va être très intéressant d’avoir un retour statistique sur ces figures chartistes, merci!

  9. CarlosFC • 66 days ago #

    Hello Nicolas and thanks a lot for your excellent work.

    I have been trying to use this indicator but, after importing it from PRT version 10.3, nothing happens.

    https://gyazo.com/fd22ce752d60add9a7ba091b21ff457e

     

    • Nicolas • 66 days ago #

      Please add it on the price chart using the wrench at the left upper side of the chart.

    • CarlosFC • 66 days ago #

      Oh yes! It works.

      Thanks a lot Nicolas.

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
pascal3431 Est ce que le screener fonctionne si l'on n'est pas en visualisation Heikin-Ashi ?
Nicolas Oui il fonctionnera de la même façon et dans tous les autres types de représentations du pri...
zen83 Merci Nicolas, génial! cela faisait un certain temps que je l'attendais, c'est un bel outil ...
Nicolas This indicator is only compatible with Prorealtime 10.3
kajsy88 I'm using prorealtime suplied by ig markets so that's potentially why then !
davidspain It would be possible to use this screener at the same time than the recent one about high vo...
Adolfo Onrubia Thanks Doctrading! Let's try something with it. :)
Doctrading Sure, I will :)
Doctrading Maybe you can also change the hourly beginning of the day (not 23PM but 12AM, OOH in french)...
Duccio Hi Doctrading,there is a way to control the max loss of the positions in this code? For exa...
Doctrading Hello, Yes, there is a command I think, but I don't know it. Nicolas knows it. You can als...
MikeGC Beautiful, Doc.  Many thanks!  For other followers of this great indicator and screener, may...
Doctrading Hello, It's a nice idea. I also tried a harami strategy with a 50 moving average, works on E...
fesxeurex Thanks for posting, Apologies if this is a dumb questions but like Chinese say "If you ask ...

Top