OPEN-SOURCE SCRIPT
Updated 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.
https://www.pulsewire.com/x/fOBEXYJd/
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
https://www.pulsewire.com/x/UB3l8bQq/
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.
https://www.pulsewire.com/x/fOBEXYJd/
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
https://www.pulsewire.com/x/UB3l8bQq/
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.
Release Notes
1. Order Result Label (TP/SL) Positioning System at Entry CandleInitial Requirement: Previous versions displayed the TP/SL label at the current candle when the order closed.
Logic Improvement:
When an order hits TP or SL, all labels and real-time tracking lines (Live PnL) will be removed to clean the chart.
Instead, a simple result text (no frame, no arrows) showing the number of pips achieved will be permanently printed in the time column of the entry candle (p.startBar).
Y-axis (price level): The display position is precisely anchored at the actual price at which the order hit (TP or SL price).
2. Dotted Line Connecting Order Holding Time
Feature: Added a horizontal dotted line (line.style_dotted).
Operational Logic:
This line starts from the horizontal axis of the Entry candle (p.startBar) and extends to the current candle that just reached the closing target (bar_index).
It is at the same price level as the result label (exitPrice).
Synchronized Color: Automatically changes to Green if the order wins or Red if the order loses, helping users easily visualize the time and price range the order has gone through.
3. Daily Profit Statistics (Today's Profit in UTC+7)
Feature: Adds the "Today's Profit" line to the Statistics table (Dashboard).
Operating Logic:
Uses an integrated time check function combined with the standard time zone: dayofmonth(time, "UTC+7").
The system continuously monitors the current day. As soon as a new day begins (starting at 00:00 UTC+7), the dailyProfitPoints counter will automatically reset to 0.
Any orders closed today (including those opened from the previous day's session) will be added to that day's profit, displayed dynamically (Green for positive, Red for negative).
4. Automatic parameter switching across 4 timeframes (Multi-Timeframe Auto-Config)
Feature: Added a checkbox "Automatically switch parameters to M5, M15, M30, H1" in the settings.
Operating logic:
Using a switch conditional statement in conjunction with Pine Script's timeframe.multiplier function, the chart is identified by the timeframe and automatically applies a specific set of parameters (with the standard structure [ATR, Factor, SL, TP]):
M5 timeframe: [14.0, 2.0, 1.5, 10.0]
M15 timeframe: [10.0, 1.0, 1.0, 10.0]
M30 timeframe: [10.0, 2.5, 2.5, 4.0]
H1 timeframe (60 minutes): [10.0, 1.5, 2.5, 8.0]
For other timeframes: Default parameters will be used automatically, or manual mode will be applied if autoAdapt is disabled.
The RSI filter parameters remain completely unchanged (RSI Period = 14, overbought/oversold levels 70/30) to ensure the stability of the signal filtering conditions.
Open-source script
In true PulseWire spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.
Open-source script
In true PulseWire spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.
