OPEN-SOURCE SCRIPT

MA & Divergence in RSI & MACD

67
This Pine Script is a multi-feature trading indicator for TradingView, titled:

🟢 "MA & Divergence in RSI & MACD"

It combines multiple moving averages, Golden/Death Cross signals, and RSI/MACD divergence detection from a lower timeframe (LTF), all on your main chart (overlay = true).


Main Features Breakdown:
The script dynamically adjusts the MA period lengths depending on your current chart timeframe:
  • Daily
  • 4-Hour
  • 1-Hour
  • Other Intraday


These affect:
Pine Script®
ma1_default = 100 // Long MA ma2_default = 200 // Very long MA ma3_default = varies // Medium MA (50-72) ma4_default = varies // Short MA (20-48) ma5_default = varies // Fast MA (7-24)



You can also choose between EMA and SMA using the input:

📊 2. Moving Average Label Display
The script shows live MA values as labels on the most recent candle. Each label includes:
  • The MA period
  • The current value
  • The type (EMA or SMA)


📈 3. Golden Cross & Death Cross Detection
Two sets of crossover events:

⚙️ Standard:
Pine Script®
goldenCross = crossover(ma3, ma1) deathCross = crossunder(ma3, ma1)

Usually, these are MA 50 crossing MA 100 (medium vs long).
Pine Script®
goldenCrossFast = crossover(ma4, ma2) deathCrossFast = crossunder(ma4, ma2)


📉 4. RSI & MACD Divergence Detection (from LTF)
Compares price movement to RSI and MACD values from a lower timeframe (default: 15 min).
Flags bullish and bearish divergence using pivot lows/highs.

🛠 Internal LTF Requests:
Uses request.security to pull lower-timeframe data into current chart:

Pine Script®
rsiLtf = request.security(..., ltf, ta.rsi(...)) macdLtf = request.security(..., ltf, macdLineOnly(...)) priceLowLtf = request.security(..., ltf, low) priceHighLtf = request.security(..., ltf, high)

🔔 5. Alerts
Supports these alerts:
  • Golden Cross
  • Death Cross
  • Bullish Divergence
  • Bearish Divergence


✅ Use Case Example
If you’re on a 1H or 4H chart:
  • The script will auto-tune MA lengths
  • Pull divergence signals from 15-min RSI and MACD
  • Show if you’ve got a bullish divergence forming while a Golden Cross just occurred
  • Provide a visual + alert-based system to decide trade entries/exits


免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。