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"
You must be logged in to post a comment.
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"
Sure, I will :)
Thanks Doctrading! Let's try something with it. :)
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