Supertrend - Optimised Exit
May 12, 2023

The Supertrend - Optimised Exit indicator allows users to analyze and identify optimal static stop-loss (SL) and profit-target (PT) percentages for a strategy based on historical performance. By evaluating a grid of potential exit points, the tool helps traders save time and improve strategy efficiency by replacing manual testing with automated performance metrics.
Usage
This tool can be used to determine which static exit levels would have historically yielded the best results for a Supertrend-based strategy. The script processes signals and calculates various performance metrics for a range of stop-loss and take-profit values.
- Grid Optimization: The script checks a range of exit percentages starting from a "Base" value and incrementing by a "Step" value.
- Metric Comparison: It computes the Total Return, Maximum Drawdown (Max DD), and Profit Factor for every point in the grid.
- Visual Feedback: Results are displayed in a clean table format, allowing you to see the top-performing exits at a glance.
- Custom Signal Integration: While configured for Supertrend by default, the logic is designed to be adaptable for other entry signals.
Details
The indicator works by simulating a strategy over historical data. It tracks the "Maximum Favorable Excursion" (MFE) and "Maximum Adverse Excursion" (MAE) for each trade. By comparing these values against a matrix of potential TP and SL levels, the script determines if a trade would have hit a target or a stop before the strategy's native exit signal occurred. This implementation uses Pine Script matrices to handle high-volume calculations efficiently without requiring multiple strategy properties.
Settings
Table Setting
- Table Location: Sets the position of the results table on the chart.
- Table Size: Adjusts the scaling of the display table.
- Table Colors: Customizes the colors for the title, cells, and positive/negative performance values.
Supertrend Indicator
- ATR Length: Sets the lookback period for the Average True Range used in Supertrend.
- Factor: Determines the multiplier applied to the ATR.
- Show Supertrend Line?: Toggles the visibility of the underlying Supertrend indicator on the chart.
Equity
- Starting Equity: The initial capital used for performance calculations.
- Investment (%): The percentage of equity allocated to each simulated trade.
Exit Trade Optimization
- Base (%): The starting percentage for the optimization grid.
- Step (%): The incremental value added to the base for each subsequent grid point.
- Number of Points: The total number of exit levels to test (up to 100).
FAQ
How do I access Supertrend - Optimised Exit?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Can I use this with my own signals?
Yes, the script is structured so that the Supertrend signals can be replaced with any custom Boolean conditions for long and short entries.
Does this guarantee future performance?
No, the script performs historical backtesting. Past performance is not necessarily indicative of future results, as market conditions are subject to change.
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.