OPEN-SOURCE SCRIPT

EMA20 Reversal Hammer Entry (Long Only)

192
EMA20 Reversal Hammer Entry (Long Only)

A Pine Script v5 indicator for TradingView that flags the first bullish reversal off the 20 EMA after a confirmed upmove.

What It Does
Upmove (Arm the setup): Detects a swing high that forms above the 20 EMA.
Pullback: Price pulls back down and touches (or slightly pierces) the 20 EMA.
Reversal (Entry signal): A Hammer or Bullish Engulfing candle appears at the EMA and closes back above it.
Reset: Once a signal fires, the setup disarms. It won't fire again until a new swing high forms — so you only get the first reversal per upmove, not every touch.
How to Add It to TradingView
Open TradingView → open any chart.
Click Pine Editor (bottom panel).
Delete the default template code.
Paste in the full indicator script.
Click Add to Chart.
Inputs
Input Default What It Controls
EMA Length 20 Length of the moving average used for the setup
Pivot Left Bars 3 Bars to the left required to confirm a swing high
Pivot Right Bars 3 Bars to the right required to confirm a swing high (adds lag but improves reliability)
EMA Touch Tolerance % 0.1 How close price needs to get to the EMA to count as a "touch." Set to 0 for a strict touch/pierce only
Reading the Chart
Orange line — the 20 EMA.
Light green background — the setup is "armed" (upmove confirmed, waiting for a pullback + reversal candle).
Green "BUY" label below a candle — the entry trigger fired.
Setting Up Alerts
Right-click the chart → Add Alert (or click the clock/alarm icon).
Under Condition, choose this indicator: "EMA20 First Reversal Entry (Long Only)".
Select the alert condition: "EMA20 First Reversal Buy".
Set trigger to Once Per Bar Close (recommended, avoids repainting/false triggers mid-candle).
Choose your notification method (popup, email, SMS, webhook, etc.).
Click Create.
Things to Keep in Mind
Long only — this version does not look for short setups.
No built-in stop-loss or invalidation logic — if price breaks down through the EMA without reversing, the setup simply stays armed until a new swing high forms. You'll want your own risk management rules alongside this.
Pivot detection has lag — a swing high isn't confirmed until Pivot Right Bars have passed, so the "armed" state appears a few bars after the actual high.
Candle pattern detection is simplified (basic hammer/engulfing logic) — not a full pattern-recognition library. Works well for clean setups but can miss edge cases.
Possible Future Add-Ons
Stop-loss / invalidation rule (e.g., cancel "armed" state if price closes far below the EMA without reversing)
Short-side mirror logic
Risk/reward or target levels plotted automatically
Strategy version (with backtesting stats) instead of just an indicator

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.