Certainly! Below is a Pine Script indicator for TradingView that identifies Shooting Star candlestick patterns with high volume. This script allows users to:
- Adjust the number of candles to consider for determining the prior trend (lookback period).
- Modify the Shooting Star Body Ratio and Shooting Star Wick Multiplier parameters.
//@version=5
indicator("Shooting Star with High Volume Detector", overlay=true)
// User inputs
lookbackPeriod = input.int(5, title="Lookback Period", minval=1)
shootingStarBodyRatio = input.float(0.35, title="Shooting Star Body Ratio")
shootingStarWickMultiplier = input.float(3.0, title="Shooting Star Wick Multiplier")
// Calculate average volume over the lookback period
avgVolume = ta.sma(volume, lookbackPeriod)
// Calculate candle components
realBody = math.abs(close - open)
upperWick = high - math.max(close, open)
lowerWick = math.min(close, open) - low
candleRange = high - low
// Prevent division by zero
candleRange := candleRange == 0 ? na(1e-10) : candleRange
// Calculate body ratio to candle range
bodyRatio = realBody / candleRange
// Condition 1: Small real body relative to the candle range
smallBody = bodyRatio <= shootingStarBodyRatio
// Condition 2: Upper wick is longer than lower wick
upperWickLonger = upperWick > lowerWick
// Condition 3: Upper wick is at least 'shootingStarWickMultiplier' times the real body
upperWickLongEnough = upperWick >= (shootingStarWickMultiplier * realBody)
// Condition 4: Volume higher than average over the lookback period
highVolume = volume > avgVolume
// Condition 5: Prior uptrend over the lookback period
uptrend = close > close[lookbackPeriod]
// Combine all conditions to identify a Shooting Star pattern
isShootingStar = smallBody and upperWickLonger and upperWickLongEnough and highVolume and uptrend
// Plot a marker on the chart when a Shooting Star is detected
plotshape(isShootingStar, title="Shooting Star", style=shape.labeldown, location=location.abovebar, color=color.red, text="Shooting Star", textcolor=color.white)
How the Indicator Works:
-
User Inputs:
- Lookback Period (
lookbackPeriod): Number of previous candles to consider for determining the prior uptrend and calculating average volume.
- Shooting Star Body Ratio (
shootingStarBodyRatio): The maximum ratio of the real body to the total candle range for a candle to be considered a Shooting Star.
- Shooting Star Wick Multiplier (
shootingStarWickMultiplier): The minimum multiple that the upper wick must be relative to the real body.
-
Candle Component Calculations:
- Real Body: The absolute difference between the close and open prices.
- Upper Wick: The distance from the higher of the close or open to the high price.
- Lower Wick: The distance from the lower of the close or open to the low price.
- Candle Range: The difference between the high and low prices.
-
Conditions for Identifying a Shooting Star:
- Small Real Body (
smallBody): The real body is less than or equal to the specified ratio of the candle range.
- Upper Wick Longer than Lower Wick (
upperWickLonger): Ensures the upper wick is dominant.
- Upper Wick Length (
upperWickLongEnough): The upper wick is at least a specified multiple of the real body.
- High Volume (
highVolume): The volume is greater than the average volume over the lookback period.
- Prior Uptrend (
uptrend): The current close is higher than the close from lookbackPeriod bars ago.
-
Plotting:
- When all conditions are met, the script plots a label above the bar indicating a Shooting Star pattern.
How to Use:
Example:
- Identify Reversals: Use this indicator to spot potential bearish reversals after an uptrend, which is characterized by the Shooting Star pattern with high volume.
- Combine with Other Analysis: Always consider additional indicators and market analysis to confirm the signals provided by the Shooting Star pattern.
Note: Trading involves risks, and candlestick patterns should not be used in isolation. It's recommended to combine them with other technical analysis tools and to test the indicator thoroughly before using it in live trading.