This Pine Script v6 component calculates and plots a "Fear Oscillator" based on the presence of bearish candlestick patterns (Shooting Star, Hanging Man, and Bearish Engulfing) over a user-defined lookback period.
How It Works:
User Inputs: length - The lookback period for calculating the oscillator, shootingStarThreshold - The threshold for identifying Shooting Star patterns, hangingManThreshold - The threshold for identifying Hanging Man patterns, engulfingThreshold - The threshold for identifying Bearish Engulfing patterns.
Pattern Detection: The script defines functions to detect Shooting Star, Hanging Man, and Bearish Engulfing patterns based on wick and body size ratios. Each pattern is checked for the given thresholds.
Score Calculation: The script calculates scores for each bearish pattern over the lookback period. These scores are normalized by dividing by the total number of candles in the period.
Fear Oscillator: The oscillator is calculated as the average of the normalized scores for the three patterns.
Plotting: The Fear Oscillator is plotted on the chart, with reference lines for "Low Fear" and "High Fear" levels.
This indicator is designed to provide a visual representation of market fear, making it a valuable tool for traders to assess bearish sentiment and identify potential reversal points or areas of heightened market risk. It is best used in conjunction with other technical analysis tools to confirm signals.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.