Supertrend with TP
May 14, 2022

The Supertrend with TP indicator is a strategy-oriented tool designed to automate the execution of Supertrend-based trades while incorporating a multi-level take-profit system. It helps traders manage their exits by scaling out of positions at predefined percentage targets, enhancing risk management and profit consistency.
Usage
The strategy initiates a position when the Supertrend direction changes—buying when the price crosses above the Supertrend line and selling when it crosses below. Once a position is opened, the script automatically places up to five take-profit (TP) limit orders.
Traders can use this tool to:
- Automate Entries: Enter long or short positions based on classic Supertrend trend-following logic.
- Scale Out of Positions: Set specific percentage amounts of the total position to be closed at various price targets (e.g., close 25% at a 2% gain, 50% at a 5% gain, etc.).
- Backtest Trend Performance: Evaluate how a trend-following approach performs over specific historical periods using the built-in date range filters.
It is essential to ensure that the cumulative "Amount (%)" of all enabled Take Profit levels equals 100% for a complete exit, or less if you intend to let a "runner" portion remain until a trend reversal occurs.
Details
The script utilizes the standard ta.supertrend function, which calculates trend direction based on a combination of Average True Range (ATR) and a multiplier (Factor). The core logic monitors for direction changes to trigger entry signals.
To facilitate integration with third-party automation platforms like Wunderbit, the script includes customizable ID fields for alerts and specific toggles to confirm external platform alignment. The strategy also includes a date range filter, allowing users to restrict backtesting or live execution to a specific window of time.
Settings
Supertrend
- ATR Length: The lookback period used to calculate the Average True Range.
- Factor: The multiplier applied to the ATR to determine the distance of the Supertrend line from the price.
Date Range
- Start / End: Toggles to enable or disable specific start and end dates for the strategy execution.
- Start Period / End Period Time: The specific timestamps for the trading window.
Take Profits (TP1 - TP5)
- TP [Number] (Toggle): Enables or disables a specific take-profit level.
- TP Level (%): The percentage price change from the entry price required to trigger the limit order.
- Amount (%): The percentage of the current position size to close at this level.
Wunderbit Settings
- Enter Long/Short ID: Custom strings used in order comments for integration with automated trading bots.
FAQ
How do I use the Supertrend with TP?
You can apply the script to your chart and adjust the ATR Length and Factor to fit your asset's volatility. Once configured, ensure your Take Profit amounts are set to manage your exit strategy effectively.
Can I use this for automated trading?
Yes, the script includes "Wunderbit ready" features, including custom order IDs and comment fields that can be utilized by webhook-based automation platforms.
Where can I get access to this tool?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.