PROTECTED SOURCE SCRIPT

Candlestick Pattern Detector with Smart Context Signals

41
This indicator identifies and labels classic candlestick patterns—such as Doji, Hammer, Shooting Star, Engulfing, Morning Star, Evening Star, Piercing Line, Dark Cloud Cover, Three White Soldiers, and Three Black Crows—and automatically translates each into a directional trading bias.

What makes it unique is its context-aware logic. It doesn’t just detect shapes—it interprets them based on recent market behavior.
By combining candle structure ratios with a trend-recognition filter (ta.rising and ta.falling), it distinguishes whether a pattern is likely a reversal or a continuation.
For example:

A long-wick candle after a series of falling closes is labeled Hammer → Long.

The same candle during a rising trend becomes Hanging Man → Short.

The script uses adaptive thresholds instead of fixed pip distances, calculating the 5-bar simple moving average of both body size and total candle range.
All pattern definitions are expressed as proportional relationships (for instance, a Doji body ≤ 10 % of average body size and total range ≥ 80 % of average).
This allows the algorithm to scale automatically across instruments and timeframes.

Visual outputs:

Pattern name and trade direction label above or below candles

Green triangles for Long setups, red for Short, Grey for neutral

Built-in alerts fire once per new signal to prevent repetitive notifications

This tool helps traders read price action rather than rely solely on indicators, offering an educational bridge between visual candlestick analysis and coded automation.

免責聲明

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.