OPEN-SOURCE SCRIPT
reversal candle

This indicator is a Technical Reversal Pattern Suite designed to identify specific candlestick formations that suggest a potential change in market direction. It combines trend filtering, volume analysis, and pattern recognition into a single tool.Here is a breakdown of how it works:1. Trend Filter (9 SMA)The indicator uses a 9-period Simple Moving Average (SMA) as the "filter" for the entire system.Why? Reversal patterns are highly contextual. A pattern that looks like a reversal in a downtrend is actually a "continuation" pattern if the overall trend is strongly upwards. By requiring the price to be on a specific side of the 9 SMA, the script ensures you are only looking for trades that align with the short-term momentum.2. Pattern Recognition LogicThe script looks for six distinct candlestick patterns, split by the trend they appear in:PatternCategoryLogicEngulfing (BE/BU)Trend ReversalOne candle's body completely "eats" or engulfs the previous candle's body, signaling a shift in control.Hammer (HM)BullishSmall body at the top with a long lower shadow; implies sellers were rejected.Inverted Hammer (IH)BullishSmall body at the bottom with a long upper shadow; shows buyers testing the resistance.Shooting Star (SS)BearishSmall body at the bottom with a long upper shadow; implies buyers were rejected at a peak.Hanging Man (HM)BearishSmall body at the top with a long lower shadow; implies that despite a low price, sellers are stepping in during an uptrend.3. Volume ConfirmationThe script includes a Volume Filter that calculates the average volume over the last 20 periods (ta.sma(volume, 20)).The Logic: A reversal pattern is considered "weak" or "noisy" if it happens on low volume. By requiring volume > volAvg, the indicator ensures that the pattern is backed by significant market participation, which increases the probability that a "real" move is occurring.4. Visual ManagementDynamic Labels: It uses a latestLabel variable to ensure that only the most recent signal remains on your screen, preventing historical clutter.Highlighting: It uses barcolor() to change the candle color the moment a pattern is detected, making the signal immediately visible without needing to check the labels.Summary of Indicators UsedMoving Averages: 9 SMA (Trend), 20 SMA (Volume).Candlestick Math: Uses the relationship between open, close, high, and low to calculate bodySize and shadow lengths.Logical Confluence: It forces four conditions to be true simultaneously before alerting: Trend direction + Pattern geometry + Volume threshold + Logic validity.This tool is designed to act as a "Decision Point" indicator. It does not tell you to buy or sell, but rather tells you when the market has reached a state of "exhaustion" where a reversal is statistically more likely to happen.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.