TrendLines with Alerts
Nov 29, 2019

The TrendLines with Alerts indicator provides an automated approach to identifying and plotting dynamic support and resistance levels based on price action geometry. It aims to simplify trendline analysis by calculating specific angles from local peaks and troughs to project future price targets and potential breakout zones.
Usage
The script can be used to identify trend direction and potential reversal points. It automatically plots upper (resistance) and lower (support) trendlines based on high and low pivot points defined by the user settings.
- Trend Identification: When the price is consistently reacting to the lower trendline, it indicates a bullish support structure. Conversely, reactions to the upper trendline indicate bearish resistance.
- Breakout Trading: The indicator generates buy and sell signals based on crossovers or specific price interactions with the projected lines. For example, a "Buy" signal may appear when price crosses over a projected upper trendline or maintains support at a lower trendline.
- Refined Projections: The script uses an "extend" logic to project trendlines forward, allowing traders to anticipate where price might encounter friction in the future.
Details
The script operates by finding the highest high and lowest low within a specified lookback period ("Length 1"). It then uses a "Check" parameter to confirm these pivots. Once a pivot is confirmed, the script calculates the slope (angle) between the current pivot and the previous one.
This slope is then used to project the line forward. Unlike standard linear regression lines, these lines are anchored to specific price extremes, making them more reactive to recent price volatility. The script has been updated to Pine Script v6 to ensure compatibility with modern charting features and includes built-in strategy logic for backtesting entry and exit conditions.
Settings
- Length 1: Determines the lookback period for identifying the highest highs and lowest lows.
- Check: Sets the offset used to confirm a pivot point and calculate the trajectory.
- Take Profit (%): The percentage-based target for the built-in strategy component.
- Stop Loss (%): The percentage-based risk limit for the built-in strategy component.
- What trades should be taken: Filters the strategy to execute "LONG", "SHORT", "BOTH", or "NONE".
- Initial Stop Loss/Target Profit Points: Allows for point-based exit conditions instead of percentages.
- Backtest Period: Inputs to define the specific start and end dates for the strategy performance report.
FAQ
How do I use the signals from this indicator?
The signals (Buy/Sell shapes) are generated when price interacts with the calculated trendlines. Traders often use these as confluence for existing strategies or as standalone breakout/rejection alerts.
Can I adjust the sensitivity of the lines?
Yes, by modifying "Length 1" and "Check," you can make the trendlines more or less responsive to short-term price fluctuations. Smaller values result in tighter, more frequent trendlines.
How can I access TrendLines with Alerts?
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.