The updated Hammer and Shooting Star Alerts script provides advanced functionality for detecting hammer and shooting star candlestick patterns across multiple timeframes, while ensuring the alerts only trigger when the daily and hourly candles are aligned (or close) in terms of their price direction (bullish or bearish).
Key Features:
Hammer and Shooting Star Detection:
The script identifies hammer and shooting star candlestick patterns on the 1-minute, 5-minute, 15-minute, and 30-minute timeframes.
The patterns are determined based on specific criteria regarding the body, upper shadow, and lower shadow of the candlesticks.
Timeframe Alignment:
The alert conditions are only met when both the daily and hourly candles share the same color (i.e., both are either bullish or bearish).
If the hourly and daily candles are within $1 of each other in terms of closing price, a special yellow background color is used to highlight the alignment.
The hourly timeframe can be slightly different from the daily timeframe as long as they are within a $1 range, which makes the background yellow.
Alert Table:
An alert table is displayed at the bottom center of the chart. This table shows the status of the candlestick pattern detection on each of the timeframes (1-min, 5-min, 15-min, 30-min).
Green Background: If the daily and hourly candles are both bullish (i.e., open < close), the background of the table cell will be green.
Red Background: If the daily and hourly candles are both bearish (i.e., open > close), the background will be red.
Yellow Background: If the daily and hourly candles are within $1 of each other in price, the background will be yellow, indicating that the candles are closely aligned but not fully matching.
Alerts:
When a hammer or shooting star pattern is detected on any of the selected timeframes and the daily/hourly candles are aligned (or within $1), an alert is triggered with the message: "Hammer or Shooting Star detected on aligned timeframes!"
This ensures that the alerts you receive are relevant to the current market sentiment on both higher and lower timeframes.
Visuals:
Arrow Plotting: The pattern detection will result in arrows on the chart pointing to the exact candlesticks that meet the hammer or shooting star criteria. The color of the arrows will align with the color of the daily candle, ensuring consistency with the overall trend.
Background Coloring: The background color of each timeframe's alert cell in the table reflects whether the daily and hourly candles are bullish, bearish, or within $1 of each other.
Improvements:
Compatibility: The script now works on Pine Script Version 6, ensuring up-to-date compatibility and the ability to handle type declarations properly.
Improved Background Logic: The background color now reflects the current price direction based on the most recent open and close prices, ensuring accurate market trend alignment.