Indicator · Pine Script v5 · On the chart

Shooting Star and Inverted Hammer Pattern

by augustoerni

This indicator identifies Shooting Star and Inverted Hammer candlestick patterns overlayed directly on the price chart.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code34
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago9 Aug 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

34 lines of Pine Script v5 from candlesticks/shooting_star_inverted_hammer.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

shooting_star_inverted_hammer.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AugustoErni

//@version=5
indicator("Shooting Star and Inverted Hammer Pattern (Candlestick Pattern)", overlay=true)

import AugustoErni/uptrend_downtrend_loopback_candle_identification_lib/3 as upAndDownTrendsCandleIdentification

showShootingStar = input.bool(defval=true, title="Show Shooting Star", tooltip="Show or hide the Shooting Star pattern.")
showInvertedHammer = input.bool(defval=true, title="Show Inverted Hammer", tooltip="Show or hide the Inverted Hammer pattern.")
lookbackPeriod = input.int(defval=5, title="Lookback Period", minval=1, step=1, tooltip="Loopback period to identify uptrend/downtrend analysis from candles.")
weakCandleThreshold = input.float(0.45, title="Weak Candle Threshold (0.45 = 45%)", step=0.01)
upperShadowThreshold = input.float(1, title="Upper Shadow Threshold (1 = 1 times the body length)")
noLowerShadowThreshold = input.float(0.05, title="No/Lower Shadow Threshold (0.05 = 5%)", step=0.01)

isBullishCandle = close > open
isBearishCandle = open > close

isLookbackDowntrendCandle = upAndDownTrendsCandleIdentification.downtrendLoopbackCandleIdentification(lookbackPeriod)
isLookbackUptrendCandle = upAndDownTrendsCandleIdentification.uptrendLoopbackCandleIdentification(lookbackPeriod)

isWeakCandle = math.abs(close - open) <= (high - low) * weakCandleThreshold
isLongUpperShadow = (high - math.max(open, close)) >= upperShadowThreshold * math.abs(open - close)
isNoLowerShadow = (math.min(open, close) - low) <= (high - low) * noLowerShadowThreshold

isShootingStar = isWeakCandle and isLongUpperShadow and isNoLowerShadow and isLookbackUptrendCandle

isInvertedHammer = isWeakCandle and isLongUpperShadow and isNoLowerShadow and isLookbackDowntrendCandle

barcolor(isShootingStar and isBullishCandle ? color.white : isShootingStar and isBearishCandle ? color.black : na)
barcolor(isInvertedHammer and isBullishCandle ? color.white : isInvertedHammer and isBearishCandle ? color.black : na)

plotshape(isShootingStar and showShootingStar, title="Shooting Star", style=shape.arrowdown, location=location.abovebar, color=color.rgb(0, 0, 0), text="Shooting Star", textcolor=color.red)
plotshape(isInvertedHammer and showInvertedHammer, title="Inverted Hammer", style=shape.arrowup, location=location.belowbar, color=color.rgb(255, 255, 255), text="Inverted Hammer", textcolor=color.green)

Overview

Shooting Star and Inverted Hammer Pattern evaluates candle body weakness, upper shadow length, and lower shadow proportions in combination with a trend lookback calculation. A Shooting Star is detected during uptrends, while an Inverted Hammer is detected during downtrends. The script plots labeled arrows above or below matching bars and recolors the candles. Users can adjust parameters for trend lookback, shadow ratios, and body size thresholds.

Details

Published by

augustoerni on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Candlestick patterns, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Show Shooting StarbooltrueshowShootingStar
Show Inverted HammerbooltrueshowInvertedHammer
Lookback Periodint5lookbackPeriod
Weak Candle Threshold (0.45 = 45%)float0.45weakCandleThreshold
Upper Shadow Threshold (1 = 1 times the body length)float1upperShadowThreshold
No/Lower Shadow Threshold (0.05 = 5%)float0.05noLowerShadowThreshold
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

All Candlestick Patterns

by shunjizhan
292 stars

All Candlestick Patterns detects and highlights a wide range of bullish, bearish, and neutral candlestick patterns directly on the price chart. It features optional trend filtering using either a 50-period simple moving average or a combination of 50-period an

Indicator v4 Candlestick patternsTrend
Updated 3 years ago · None stated GitHub repository of All Candlestick Patterns
257 stars

This indicator detects a large set of classic candlestick patterns and plots colored labels on the price chart. Trend context uses a 50-period simple moving average, or the 50 and 200 averages stacked together, and can be switched off. Users filter bullish, be

Indicator v4 Candlestick patternsTrend
Updated 6 weeks ago · None stated GitHub repository of Snag - All Candlestick Patterns

Five-in-one Strategy

by capissimo
114 stars

Five-in-one Strategy combines five analytical tools into a single price chart overlay: the Dual Thrust Trading Algorithm (DTTA), Semafore, HalfTrend, Nick Rypock Trailing Reverse, and Tweezer or Kangaroo Tail candlestick patterns. It generates trade signals us

Indicator v4 TrendBreakout Repaints
Updated 1 year ago · None stated GitHub repository of Five-in-one Strategy

HA: Heikin-Ashi

by mihakralj
99 stars

This indicator calculates and plots Heikin-Ashi smoothed candlesticks directly on the price chart. It derives the smoothed close from standard price averages and recursively computes the open, high, and low values. The script does not issue trade signals or al

Indicator v6 Candlestick patternsTrend
Updated 4 weeks ago · Apache-2.0 GitHub repository of HA: Heikin-Ashi
55 stars

This indicator overlays on the price chart and provides trend and momentum analysis. It calculates and plots three exponential moving averages with fixed periods of 20, 50, and 200 using yellow, orange, and blue colors respectively. The script also computes th

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · Apache-2.0 GitHub repository of Trend & Momentum Analysis

Confluence Suite

by TamaraKGreen
46 stars

The Confluence Suite indicator draws multiple trading signals and tools directly on the price chart. It generates entry and exit signals based on selected modes and filters, with an AI signal classifier rating quality from 1-4. Additional features include smar

Indicator v5 TrendSMC / ICT / price action
Updated 7 weeks ago · None stated GitHub repository of Confluence Suite

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers