Supertrend + RSI Filter (Advanced TP/SL)OverviewThe Supertrend + RSI Filter (Advanced TP/SL) is a comprehensive trend-following indicator designed for PulseWire (Pine Script v5). It combines the trend-detection power of the Supertrend with a dynamic RSI Momentum Filter to eliminate low-probability setups in overbought or oversold conditions.Unlike standard indicators that clear historical lines upon new signals, this script implements a Pine Script v5 Custom Type & Array-based Position Management System. It tracks every trade independently, drawing dynamic Entry, Take Profit (TP), and Stop Loss (SL) lines with centered price labels. Position lines persist on the chart and are ONLY removed when price action officially hits the TP or SL level.
Comprehensive Feature List
Supertrend Trend Detection:
Utilizes Average True Range (ATR) to measure volatility and establish dynamic trailing stop bands for precise trend-direction identification.
RSI Momentum Filtering:
- Buy Filter: Suppresses BUY signals when RSI exceeds the overbought threshold (Default: >70) to prevent buying at local tops.
- Sell Filter: Suppresses SELL signals when RSI drops below the oversold threshold (Default: <30) to prevent selling at local bottoms.
Can be toggled ON/OFF in the settings menu.
Multi-Position Tracking Arrays:
- Employs custom data structures () stored in an to track multiple open trades concurrently. type Position array
- Persistent Lines: Entry (Solid Gray), Take Profit (Dashed Green), and Stop Loss (Dashed Red) lines remain on the chart through opposite trend changes until hit. - Centered Price Labels: Displays label text (, , ) dynamically anchored at the midpoint of each active position line. Entry: XTP: YSL: Z
- Individual Removal: When a specific trade hits its TP or SL target, its corresponding lines and labels are erased immediately without affecting other active trades.
On-Chart Performance Dashboard:
- Displays an updated summary table in the top-left corner of the chart.
- Metrics Included:
Win Rate (%): Percentage of closed trades hitting TP.
Total Trades: Total number of completed historical signals.
Winning & Losing Trades: Count of successful vs. failed setups.
Total Profit (Pips): Cumulative net profit/loss expressed in pips.
RSI Filter Status: Visual indicator showing whether the filter is active ( / ).ONOFF
Dynamic & Multi-Parameter Alert System:
Uses Pine Script’s function to output real-time formatted text messages containing key execution metrics: alert()
Symbol / Ticker
Timeframe
Exact Entry Price
Target Take Profit Price
Target Stop Loss Price
including warnings. alertcondition()
Trading & Exit Logic
1. BUY Setup
Trigger: Supertrend flips from Bearish (Red) to Bullish (Green).
Filter Condition: $\text{RSI} \le \text{Overbought Threshold}$ (or RSI Filter disabled).
Entry: Closing price of the signal bar.
Stop Loss: $\text{Entry} - (\text{ATR} \times \text{SL Multiplier})$
Take Profit: $\text{Entry} + (\text{ATR} \times \text{TP Multiplier})$
2. SELL Setup
Trigger: Supertrend flips from Bullish (Green) to Bearish (Red).
Filter Condition: $\text{RSI} \ge \text{Oversold Threshold}$ (or RSI Filter disabled).
Entry: Closing price of the signal bar.
Stop Loss: $\text{Entry} + (\text{ATR} \times \text{SL Multiplier})$
Take Profit: $\text{Entry} - (\text{ATR} \times \text{TP Multiplier})$
3. Exit & Removal Logic
On every historical and real-time bar, the script checks if or crosses the target levels: High Low
BUY Hit TP: $\text{High} \ge \text{TP Price}$
BUY Hit SL: $\text{Low} \le \text{SL Price}$
SELL Hit TP: $\text{Low} \le \text{TP Price}$
SELL Hit SL: $\text{High} \ge \text{SL Price}$
Upon trigger, the specific position is logged into the performance table, and its lines/labels are deleted.
Settings & Inputs
How to Set Up Dynamic Alerts
Apply the indicator to your desired chart.
Click the Alerts icon (Clock) on PulseWire $\rightarrow$ Create Alert.
Under Condition, select: .Supertrend + RSI Filter (Advanced TP/SL)
Select Any alert() function call in the dropdown menu.
Set the frequency to Once Per Bar Close.
Click Create. You will receive detailed alerts formatted like this:
🚀 BUY SIGNAL
Symbol: BTCUSDT
Timeframe: 15
Entry: 64250.50
TP: 65120.00
SL: 63815.25
Risk Disclosure & Limitations
Choppy / Ranging Markets: As a trend-following tool, Supertrend may produce consecutive false breakouts when the market moves sideways.
Backtest Statistics Notice: The statistics table measures theoretical performance based on bar high/low historical data. It does not account for slippage, spread, overnight funding fees, or broker commissions.
Repainting Disclaimer: Signals and position calculations are confirmed on bar close ( / ) to strictly avoid repainting. barstate. islastfreq_once_per_bar_close
Financial Disclaimer: This script is developed strictly for educational and analytical purposes. It does not constitute financial or investment advice. Always manage your risk responsibly.
Indicator

