All indicators

Trend Lines, Supports and Resistances

Jan 3, 2024

Static chart image
Support and ResistanceSignalsPivot Based (Retrospective)

The Trend Lines, Supports and Resistances indicator is a comprehensive charting tool designed to automatically identify and visualize critical price levels and trend trajectories based on pivot highs and lows. It helps traders distinguish between active market structures and historical zones by dynamically managing trend lines and support/resistance areas.

Usage

The script automatically detects pivots and uses them to construct two main types of technical analysis elements:

  • Trend Lines: The tool connects a user-defined number of pivot points to draw diagonal trend lines. It includes advanced filtering, such as "Maximum Violation," which allows lines to stay active even if price briefly breaches them, and "Excepted Last Bars" to prevent premature alerts or removals during recent volatility.
  • Support and Resistance (S&R): Horizontal zones are drawn based on pivot points. These boxes visualize the area between the candle wick and the body, providing a clearer zone of interest than a single line.
  • Alerting: Users can enable alerts for price breaking through trend lines or S&R levels. The frequency of these alerts (per bar, per bar close, or every tick) can be adjusted in the settings.

Details

The indicator relies on the calculation of pivots over a specific "Pivot Length." Once a pivot is confirmed, the script evaluates the relationship between historical pivots to form trend lines.

  • Trend Line Logic: It checks multiple point combinations to find the most relevant diagonal trends.
  • Violation Logic: The tool differentiates between "active" and "violated" lines. Users can choose to display violated trend lines as "ghost" lines (dotted) to see where previous market structures existed.
  • Box Implementation: Support and resistance levels are drawn using boxes that span from the pivot's extreme price to the nearest candle body, providing a volume-weighted sense of the level.

Settings

Pivot Points ・ Common

  • Pivot Length: The number of bars required on each side to confirm a high or low pivot.
  • Mark Pivots: Toggles the visual markers (shapes) on the chart where pivots are detected.
  • Alerts Enabled / Frequency: Controls the master alert toggle and how often alerts trigger for pivot detection.

Trend Lines

  • Enabled: Toggles the calculation and display of diagonal trend lines.
  • Points to Check: The number of historical pivots the script analyzes to find valid trend lines.
  • Maximum Violation: Sets how many times price can cross a trend line before it is considered broken.
  • Excepted Last Bars: Ignores violations occurring within the most recent "n" bars.
  • Show Violated Trend Lines: Displays broken trend lines as dotted "ghost" lines.
  • Line Extension: Sets whether the lines extend to the left, right, both, or none.

Supports & Resistances

  • Enabled: Toggles the horizontal S&R zones.
  • Points to Check: Number of pivots used to identify S&R levels.
  • Maximum Violation Allowed: How many times price can breach a horizontal level before it is removed.
  • Excepted Last Bars: Ignores breaches in the most recent bars to avoid noise.

FAQ

How do I use the "Maximum Violation" setting?

This setting allows you to filter out market noise. If set to 1, the trend line or support level will remain active even if the price breaches it once, only disappearing or turning into a "ghost" line after the second violation.

What are "Excepted Last Bars"?

This setting prevents the indicator from removing a line or triggering an alert if a violation happens within the most recent bars. This is useful for avoiding "false" breaks that occur during high-volatility price action before a candle closes.

How can I access this indicator?

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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.