Reversal pattern indicator
- Indicators
- Version: 1.0
- Activations: 5
The indicator automatically recognizes classic reversal candlestick patterns and visualizes them on the chart using colored arrows. Works in real time, analyzing the most recent candles.
Engulfing Patterns
Bullish Engulfing:
Previous candle is bearish, current candle is bullish
The body of the current candle completely overlaps the body of the previous one
Open[i] < Close[i-1] and Close[i] > Open[i-1]
Bearish Engulfing:
Reverse conditions: previous candle is bullish, current candle is bearish
Complete overlap of the previous candle's body
Enhanced signal if the current candle's body > 2× the previous candle's body
Hammer / Shooting Star
Criteria for both forms:
Body-to-range ratio: body/range ≤ MinBodyRatio (small body)
Shadow-to-body ratio: shadow/body ≥ MinShadowRatio (long shadow)
Pin Bars
General condition: total shadow length ≥ MinShadowRatio × body
Doji
A candle is considered a Doji if the difference between open and close does not exceed a specified number of points
The marker is placed in the middle of the range (high + low) / 2
Morning / Evening Star (3-candle patterns)
Morning Star (bullish reversal):
1. Candle 0: bearish (close < open)
2. Candle 1: small body (body ≤ 0.5 × body[0])
3. Candle 2: bullish, closes above the midpoint of the first candle's body
Evening Star (bearish reversal):
1. Candle 0: bullish
2. Candle 1: small body
3. Candle 2: bearish, closes below the midpoint of the first candle's body
Both patterns are automatically flagged as strong signals (StrongBuffer)
Notification System
When any pattern triggers, a message is generated:
"[Pattern Name] on [Symbol] [Time]"
Notifications are sent only if the following flags are enabled:
ShowAlerts — pop-up window in the terminal
ShowPush — push notification to a mobile device
Calculation Loop (OnCalculate)
1. Optimization: recalculation starts from the last modified bar (prev_calculated)
2. Buffer reset: all values are initialized as EMPTY_VALUE
3. Skip initial candles: 3-candle patterns require a minimum of 3 bars
4. Calculation of each candle's parameters: body, range, shadows, direction
5. Sequential check of all enabled patterns
6. Signal recording to the corresponding buffers with a price offset (± _Point * 5)
