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 • 225 days ago #

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

    • Nicolas • 225 days ago #

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

  2. AleX • 224 days ago #

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

  3. Doctrading • 224 days ago #

    Nice work !

  4. Pierre • 223 days ago #

    Very nice !

    This has been requested many times by PRT users.

  5. Sofitech • 209 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 • 209 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 • 209 days ago #

    ok merci. Je vais tester cela…

  7. Ashevs21 • 207 days ago #

    how do i get version 10.3??

  8. Pascal • 201 days ago #

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

  9. CarlosFC • 108 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 • 108 days ago #

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

    • CarlosFC • 108 days ago #

      Oh yes! It works.

      Thanks a lot Nicolas.

  10. Cavok • 26 days ago #

    Bonsoir, comment modifier le texte blanc en une autre couleur, le blanc étant extrèmement difficile à lire?

    Un grand bravo pour votre travail.

     

    • Nicolas • 26 days ago #

      La définition de la couleur blanche a été volontairement laissé accessible pour modification aux lignes 3,4,5 pour les utilisateurs n’utilisant pas un fond noir pour leurs graphiques (valeurs Rouge, Vert et Bleu à modifier à votre convenance).

  11. Ciccio • 16 days ago #

    There is this Metatrade 4 code that I found around, and it seems more complete than the one posted here

    Could someone kindly convert it to Prorealtime code?

    Thanks in advance

    • Nicolas • 15 days ago #

      Please use the forums instead! Don’t copy/paste codes of entire indicator in comments 🙂 You can upload file in a new forum post query for indicator translation.

  12. Reddi • 5 days ago #

    Great Nicolas and Thx,

    Nice work. IG has released today PRT 10,3 in Germany and I added the function immediately.

  13. Nicolas • 10 hours ago #

    Another indicator for almost 40 candlesticks patterns identification has been released by Ciccio and it is available here: https://www.prorealcode.com/prorealtime-indicators/candlesticks-patterns-indicator/

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar

+1 more likes

Related users ' posts
Boursomaniac In addition, if you want to get more information on how to use the candlestick and evening a...
zen83 Merci Nicolas, génial! cela faisait un certain temps que je l'attendais, c'est un bel outil ...
finplus Bonjour, merci pour ce screener qui m'intéresse énormément. Etant nul en codage, je souhaite...
Nicolas Je pense qu'il faudrait poster un nouveau sujet dans le support ProScreener du forum, on y s...
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 :)
farridin Hi Doctrading thank you very much for this code. One question as I'm new to coding, what wou...
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