OPEN-SOURCE SCRIPT
DANI _ MTF Pullback Strategy

MTF Pullback - RSI Panel Summary
Purpose: Companion indicator for the main strategy that displays RSI with divergence detection in a separate pane below the price chart.
Settings
ParameterDefaultDescriptionRSI Length14Lookback period for RSI calculationRSI Oversold Level30Threshold for oversold conditionRSI Overbought Level70Threshold for overbought conditionDivergence Lookback Bars10How many bars to look back for divergence detection
What It Displays
RSI Line — Changes color based on zone:
Purple = neutral (between 30-70)
Green = oversold (below 30)
Red = overbought (above 70)
Horizontal Levels:
Red dashed line at 70 (overbought)
Green dashed line at 30 (oversold)
Gray dotted line at 50 (midpoint)
Zone Fills:
Light red shading above 70
Light green shading below 30
Divergence Markers:
"DIV" label with lime circle = bullish divergence (price makes lower low, RSI makes higher low while oversold)
"DIV" label with fuchsia circle = bearish divergence (price makes higher high, RSI makes lower high while overbought)
Background Flash:
Green flash when bullish divergence detected
Red flash when bearish divergence detected
Divergence Logic
Bullish: Price makes a lower low AND RSI makes a higher low AND RSI is in oversold territory → potential reversal up
Bearish: Price makes a higher high AND RSI makes a lower high AND RSI is in overbought territory → potential reversal downand for the strategy15:36Outlined strategy script components and display mechanics.The user wants a summary of the main strategy script, similar to what I provided for the RSI panel. I should cover the purpose, settings, entry conditions, exit conditions, and what it displays on the chart.MTF Pullback Strategy Summary
Purpose: Multi-timeframe pullback strategy that trades trend continuations. Uses 4H timeframe for trend direction and entry timeframe (typically 15M) for precise entries based on RSI divergence and engulfing patterns.
Settings
ParameterDefaultDescriptionTimeframesHigher Timeframe240 (4H)Timeframe for trend detectionTrend FilterEMA Length50EMA period for trend directionRSIRSI Length14RSI calculation periodRSI Oversold Level30Long entry RSI thresholdRSI Overbought Level70Short entry RSI thresholdDivergence Lookback10Bars to scan for divergenceSwing DetectionSwing Lookback5Bars left/right to confirm swingRisk ManagementATR Length14ATR calculation periodStop Loss ATR Multiplier2.0SL = 2× ATR from entryTake Profit %2.0TP = entry ± 2%Trade DirectionTrade LongstrueEnable long tradesTrade ShortstrueEnable short trades
Entry Conditions
Long Entry (all must be true):
4H uptrend (price above 50 EMA + EMA rising)
Current price above 4H 50 EMA
Price pulling back from recent 4H swing high
RSI oversold (<30) or below 40
Bullish RSI divergence OR RSI turning up from oversold
Bullish engulfing candle at or within 2 bars after swing low
Short Entry (all must be true):
4H downtrend (price below 50 EMA + EMA falling)
Current price below 4H 50 EMA
Price pulling back from recent 4H swing low
RSI overbought (>70) or above 60
Bearish RSI divergence OR RSI turning down from overbought
Bearish engulfing candle at or within 2 bars after swing high
Exit Conditions
Exit TypeLongShortStop LossEntry - (2 × ATR)Entry + (2 × ATR)Take ProfitEntry × 1.02 (+2%)Entry × 0.98 (-2%)
What It Displays
On Chart:
Blue line = 4H 50 EMA
Green triangle below bar = long entry signal
Red triangle above bar = short entry signal
Green background tint = 4H uptrend active
Red background tint = 4H downtrend active
Info Table (top right):
FieldShows4H TrendUP ↑ / DOWN ↓ / NEUTRALPrice vs EMAABOVE / BELOWPullback LYES/NO (long pullback active)Pullback SYES/NO (short pullback active)Bull DivYES/NO (bullish divergence)Bear DivYES/NO (bearish divergence)
Strategy Logic Flow
4H TREND CHECK
↓
PRICE VS 50 EMA
↓
PULLBACK DETECTED?
↓
RSI CONDITION MET?
↓
RSI DIVERGENCE?
↓
ENGULFING AT SWING?
↓
ENTRY → SL (2×ATR) + TP (2%)
Alerts Available
Long Entry Signal — Triggers when all long conditions align
Short Entry Signal — Triggers when all short conditions align
Recommended Usage
Apply to 15-minute chart (fetches 4H data automatically)
Use alongside the RSI Panel indicator for visual confirmation
Backtest on trending pairs/assets (crypto, forex majors, indices)
Adjust ATR multiplier if stops are too tight/wide for your asset
Purpose: Companion indicator for the main strategy that displays RSI with divergence detection in a separate pane below the price chart.
Settings
ParameterDefaultDescriptionRSI Length14Lookback period for RSI calculationRSI Oversold Level30Threshold for oversold conditionRSI Overbought Level70Threshold for overbought conditionDivergence Lookback Bars10How many bars to look back for divergence detection
What It Displays
RSI Line — Changes color based on zone:
Purple = neutral (between 30-70)
Green = oversold (below 30)
Red = overbought (above 70)
Horizontal Levels:
Red dashed line at 70 (overbought)
Green dashed line at 30 (oversold)
Gray dotted line at 50 (midpoint)
Zone Fills:
Light red shading above 70
Light green shading below 30
Divergence Markers:
"DIV" label with lime circle = bullish divergence (price makes lower low, RSI makes higher low while oversold)
"DIV" label with fuchsia circle = bearish divergence (price makes higher high, RSI makes lower high while overbought)
Background Flash:
Green flash when bullish divergence detected
Red flash when bearish divergence detected
Divergence Logic
Bullish: Price makes a lower low AND RSI makes a higher low AND RSI is in oversold territory → potential reversal up
Bearish: Price makes a higher high AND RSI makes a lower high AND RSI is in overbought territory → potential reversal downand for the strategy15:36Outlined strategy script components and display mechanics.The user wants a summary of the main strategy script, similar to what I provided for the RSI panel. I should cover the purpose, settings, entry conditions, exit conditions, and what it displays on the chart.MTF Pullback Strategy Summary
Purpose: Multi-timeframe pullback strategy that trades trend continuations. Uses 4H timeframe for trend direction and entry timeframe (typically 15M) for precise entries based on RSI divergence and engulfing patterns.
Settings
ParameterDefaultDescriptionTimeframesHigher Timeframe240 (4H)Timeframe for trend detectionTrend FilterEMA Length50EMA period for trend directionRSIRSI Length14RSI calculation periodRSI Oversold Level30Long entry RSI thresholdRSI Overbought Level70Short entry RSI thresholdDivergence Lookback10Bars to scan for divergenceSwing DetectionSwing Lookback5Bars left/right to confirm swingRisk ManagementATR Length14ATR calculation periodStop Loss ATR Multiplier2.0SL = 2× ATR from entryTake Profit %2.0TP = entry ± 2%Trade DirectionTrade LongstrueEnable long tradesTrade ShortstrueEnable short trades
Entry Conditions
Long Entry (all must be true):
4H uptrend (price above 50 EMA + EMA rising)
Current price above 4H 50 EMA
Price pulling back from recent 4H swing high
RSI oversold (<30) or below 40
Bullish RSI divergence OR RSI turning up from oversold
Bullish engulfing candle at or within 2 bars after swing low
Short Entry (all must be true):
4H downtrend (price below 50 EMA + EMA falling)
Current price below 4H 50 EMA
Price pulling back from recent 4H swing low
RSI overbought (>70) or above 60
Bearish RSI divergence OR RSI turning down from overbought
Bearish engulfing candle at or within 2 bars after swing high
Exit Conditions
Exit TypeLongShortStop LossEntry - (2 × ATR)Entry + (2 × ATR)Take ProfitEntry × 1.02 (+2%)Entry × 0.98 (-2%)
What It Displays
On Chart:
Blue line = 4H 50 EMA
Green triangle below bar = long entry signal
Red triangle above bar = short entry signal
Green background tint = 4H uptrend active
Red background tint = 4H downtrend active
Info Table (top right):
FieldShows4H TrendUP ↑ / DOWN ↓ / NEUTRALPrice vs EMAABOVE / BELOWPullback LYES/NO (long pullback active)Pullback SYES/NO (short pullback active)Bull DivYES/NO (bullish divergence)Bear DivYES/NO (bearish divergence)
Strategy Logic Flow
4H TREND CHECK
↓
PRICE VS 50 EMA
↓
PULLBACK DETECTED?
↓
RSI CONDITION MET?
↓
RSI DIVERGENCE?
↓
ENGULFING AT SWING?
↓
ENTRY → SL (2×ATR) + TP (2%)
Alerts Available
Long Entry Signal — Triggers when all long conditions align
Short Entry Signal — Triggers when all short conditions align
Recommended Usage
Apply to 15-minute chart (fetches 4H data automatically)
Use alongside the RSI Panel indicator for visual confirmation
Backtest on trending pairs/assets (crypto, forex majors, indices)
Adjust ATR multiplier if stops are too tight/wide for your asset
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。