This Pine Script v6 component calculates and plots an "Indecision Oscillator" based on the presence of Doji and Spinning Top candlestick patterns over a user-defined lookback period.
Here's how it works:
User Inputs: length - the lookback period for calculating the oscillator, dojiThreshold - the threshold for identifying Doji patterns, spinningTopThreshold - the threshold for identifying Spinning Top patterns.
Pattern Detection: The script defines functions to detect Doji and Spinning Top patterns based on the body size relative to the total range of the candle.
Score Calculation: It calculates scores for Doji and Spinning Top patterns over the specified lookback period and normalizes these scores.
Indecision Oscillator: The oscillator is calculated as the average of the normalized Doji and Spinning Top scores.
Plotting: Only the Indecision Oscillator is plotted on the chart, with reference lines for neutral and indecision levels.
This component provides a visual representation of market indecision, which can be useful for traders looking to identify potential reversal points or periods of consolidation.