Trailing Stop Back Testing and alerts + TP and TS
Jan 24, 2016

The Trailing Stop Back Testing and alerts + TP and TS indicator provides a comprehensive framework for multi-timeframe trend analysis and automated exit management using trailing stops, take profits, and stop losses.
Usage
The Usage section focuses on how to leverage the multi-timeframe filters and the integrated trailing stop mechanism to refine trade entries and exits. This tool is designed to identify momentum alignment across four different resolutions, ensuring that trades are only taken when the trend is synchronized.
Multi-Timeframe Alignment
The script monitors the open and close relationship (candle polarity) across four user-defined timeframes. A "Long Signal" is generated when the previous candles on all four resolutions are bullish, while a "Short Signal" is generated when all four are bearish. This provides a high-probability filter for trend-following strategies.
Exit Management
The strategy incorporates several exit methods:
- Manual Trailing Stop: Based on the "Trailing Stop" input, the script tracks the highest high (for longs) or lowest low (for shorts) since entry and triggers an exit if the price retraces by the specified amount.
- Built-in Strategy Exits: Users can define fixed Take Profit (TP), Stop Loss (SL), and Trailing Stop points within the strategy settings to automate trade termination via the strategy tester and alerts.
Details
The script utilizes request.security to fetch historical candle data from multiple resolutions. By default, it can process either standard candles or Heikin Ashi candles to smooth out price action. The core logic relies on state tracking via var variables to maintain the highest high or lowest low during a trade, allowing the calculation of a dynamic trailing stop.
The implementation is optimized for the Strategy Tester, enabling users to backtest how trailing stops would have performed historically. Additionally, it features dedicated alert triggers for entry signals and trailing stop hits, facilitating integration with automated trading tools.
Settings
General Settings
- Trailing Stop: Defines the price distance (offset) used for the manual trailing stop calculation.
- HA Candles: Toggles between standard candle data and Heikin Ashi candle data for signal calculations.
Resolutions
- Resolution 1-4: Allows the user to select the four specific timeframes (e.g., 3m, 5m, 15m, 30m) that must align to trigger a trade signal.
Strategy Exit Parameters
- Take Profit: Sets the profit target level in points.
- Stop Loss: Sets the maximum loss level in points.
- Trailing Stop Exit Points: Sets the activation points for the built-in strategy trailing stop feature.
FAQ
How do I use this script for automated trading?
You can configure the alert messages within the indicator settings to connect with third-party execution platforms. The script includes specific alert triggers for Long, Short, and Trailing Stop exits.
Why are there no signals appearing on my chart?
Signals only appear when all four selected timeframes agree on the candle direction. Ensure your "Resolution" settings are appropriate for the asset and timeframe you are currently viewing.
How can I access Trailing Stop Back Testing and alerts + TP and TS?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Unlock Unlimited Access to the LuxAlgo Library
Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

