OPEN-SOURCE SCRIPT

Trendline Break & Retest Strategy + Filters

575
Trendline break and retest with filters RSI
How It Works – Step-by-Step
1. Swing High & Swing Low Detection
The script looks for pivot points:

A swing high is when a high is higher than surrounding candles.

A swing low is when a low is lower than surrounding candles.

These points act as anchor points for trendlines.

2. Simulated Trendlines
Since Pine Script can’t draw truly dynamic trendlines, it mathematically simulates:

A downward resistance trendline from the last swing high.

An upward support trendline from the last swing low.

These lines estimate where resistance or support would exist if you were manually drawing trendlines.

3. Breakout Detection
The strategy checks:

If price breaks above the resistance trendline (bullish breakout).

If price breaks below the support trendline (bearish breakout).

It looks for a clean break with candle close beyond the line, not just a wick.

4. Retest Confirmation
To avoid chasing breakouts, the strategy waits for a retest:

After a breakout, price must come back close to the broken trendline (within a % tolerance).

This simulates the classic "break → retest → go" pattern.

Only after a valid retest will the strategy consider entering.

5. Technical Filters (for Better Accuracy)
Once a valid breakout + retest is detected, the strategy applies filters:

✅ RSI Filter
Go long only if RSI > 50 (bullish momentum).

Go short only if RSI < 50 (bearish momentum).

✅ Volume Filter
Only enter trades when current volume is greater than the 20-period average, ensuring market participation.

✅ EMA Trend Filter
Long trades only if price is above the 50 EMA (uptrend).

Short trades only if price is below the 50 EMA (downtrend).

This avoids going against the dominant trend.

6. Trade Execution
Entries: After all conditions are met (break, retest, filters).

Exits: Set using:

Take Profit = +2% from entry

Stop Loss = -1% from entry

You can adjust these in the script settings.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.