Doctrading

Pin bar detection

Category: Indicators By: Doctrading Created: April 27, 2016, 10:11 AM
April 27, 2016, 10:11 AM
Indicators
7 Comments
Pin bar detection

Hello,

This is just an easy but effective code, to detect pin bars.
“Shooting stars” = bearish pin bars

“Hammer” = bullish pin bars

I don’t consider the color of the candle, but the size of the wick.

Have a good trading !

I wrote this code in order to test a strategy.

This strategy fails, but not the indicator code.

shootingstar = 0
hammer = 0

IF (high - low) > 2* abs(close - open) THEN   // définition d’une pin bar (étoile filante ou marteau)

 IF (open - low) < 0.3*(high - low) OR (close - low) < 0.3*(high-low) THEN
  shootingstar = -1
 ENDIF
 IF (high - open) < 0.3*(high - low) OR (high - close) < 0.3*(high-low) THEN
  hammer = 1
 ENDIF
ENDIF


return shootingstar as "Shooting Star", hammer as "Hammer"

 

Download
Filename: PIN-BARS.itf
Downloads: 407
Doctrading
Doctrading Master
Hello, I'm Marc. Nice to meet you.
Author’s Profile

Comments

RussJ
4 years ago
#

Hey people Some great screeners on here but I'm pulling up too many stocks when I search. If I want to add to the code search for stocks that are $100 minimum in price then how would I do this? What would be the code? Thanks R

komiko
8 years ago
#

9a marche pas ? le code sur prorealtime "erreur de syntaxe l'instruction retur et autorisée que dans le cadre de la création d'indicateurs"

Nicolas
8 years ago
#

En effet, il s'agit bien du code d'un indicateur et non d'un screener ou d'une stratégie de trading. Il faut donc copier/coller le code dans le bon éditeur de code ou alors tout simplement télécharger le fichier .itf sur cette page et l'importer.

Degardin Arnaud
9 years ago
#

Many thanks for this indi! Good results on SPA35 con Timeframe 130min, I only modify this "(high - low) > 3* abs(close - open)" //------------------------------------------------------------------------- // Codice principale : PIN v1 //------------------------------------------------------------------------- // Definizione dei parametri del codice DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate PIN = CALL "PIN" TOSELL= (PIN=-1) TOBUY= (PIN=1) IF TOSELL THEN SELLSHORT 0.2 CONTRACT AT MARKET ENDIF IF TOBUY THEN BUY 0.2 CONTRACT AT MARKET ENDIF IF LONGONMARKET AND BARINDEX-TRADEINDEX(1) >= 20 THEN SELL AT MARKET ENDIF IF SHORTONMARKET AND BARINDEX-TRADEINDEX(1) >= 20 THEN BUY AT MARKET ENDIF //------------------------------------------------------------------------- // Funzione : PIN //------------------------------------------------------------------------- shootingstar = 0 p = 5 dev = 2 BollInf = Average[p](close)-dev*std[p](close) BollSup = Average[p](close)+dev*std[p](close) IF (high - low) > 3* abs(close - open) THEN // définition d’une pin bar (étoile filante ou marteau) IF high>BollSup AND ((open - low) < 0.3*(high - low) OR (close - low) < 0.3*(high-low)) THEN shootingstar = -1 ENDIF IF low<BollInf AND ((high - open) < 0.3*(high - low) OR (high - close) < 0.3*(high-low)) THEN shootingstar = 1 ENDIF ENDIF return shootingstar as "Shooting Star"

farridin
10 years ago
#

Hi Doctrading thank you very much for this code. One question as I'm new to coding, what would be to size of the wick compared to body size for these pinbars? also is there any upper or lower shadows? is there a way to code shaven heads? thanks 

Doctrading
10 years ago
#

Sure, I will :)

Adolfo Onrubia
10 years ago
#

Thanks Doctrading! Let's try something with it. :)

ProRealCode ProRealCode
Loading...