Buy-the-Dip Indicator

TradingView Overlay Tool

What is the Buy-the-Dip Indicator?

This script is designed for trend-continuation traders. Instead of chasing a stock at its peak, this indicator identifies short-term "oversold" conditions within a larger uptrend. It paints a clear signal directly on your candles when the risk-to-reward ratio is statistically in your favor.

  • Trend Filtering: Uses a 50 EMA (Exponential Moving Average) to ensure you only buy "dips" in stocks that are structurally moving higher.
  • RSI Exhaustion: Triggers when the Relative Strength Index (RSI) drops below 35, signaling a temporary pullback.
  • Visual Alerts: Plots a green triangle under the entry candle and can send a notification to your phone or desktop.

🚀 Setup Instructions

1
Copy the Script: Click the "Copy Script" button in the black box below.
2
Open Pine Editor: In TradingView, click the "Pine Editor" tab at the bottom of your chart.
3
Install: Paste the code, click "Save," and then "Add to Chart."
Pro Tip: You can adjust the "Dip Threshold" in the settings. If you want more frequent signals, move the RSI threshold to 40. For more conservative entries, move it down to 30.
//@version=5
indicator("DTL Lab - Buy-the-Dip Visual", overlay=true)

// --- INPUTS ---
ema_len = input.int(50, "Trend Filter (EMA)", minval=1)
rsi_len = input.int(14, "RSI Length", minval=1)
rsi_low = input.int(35, "Dip Threshold (RSI)", minval=10, maxval=50)

// --- CALCULATIONS ---
ema_val = ta.ema(close, ema_len)
rsi_val = ta.rsi(close, rsi_len)

// --- LOGIC ---
// 1. Price is above the EMA (Uptrend)
// 2. RSI is below our dip threshold
// 3. RSI was previously above the threshold (Crossing down)
is_uptrend = close > ema_val
is_dip = rsi_val < rsi_low and rsi_val[1] > rsi_low

buy_signal = is_uptrend and is_dip

// --- VISUALS ---
plot(ema_val, color=color.new(color.blue, 50), title="Trend EMA")
plotshape(buy_signal, 
     style=shape.triangleup, 
     location=location.belowbar, 
     color=color.new(#28a745, 0), 
     size=size.small, 
     title="Dip Entry Signal")

// --- ALERTS ---
alertcondition(buy_signal, title="Dip Entry Detected", message="Buy the Dip signal on {{ticker}}")
Common Issues:
Too Many Signals: In highly volatile markets, the RSI can whip back and forth. Consider increasing the EMA length to 200 for a "macro" trend filter.
Signal Delay: The signal appears at the *close* of the candle to confirm the RSI level. Do not enter mid-candle as the RSI may fluctuate back above 35.
⚠️ Disclaimer: This tool is for educational purposes. Trading involves risk. Using a single indicator is never recommended; always use this in conjunction with other price action confirmation.