All indicators

Support and Resistance

Jun 5, 2020

Static chart image
Support and ResistanceSignalsPivot Based (Retrospective)

The Support and Resistance indicator automatically identifies and plots horizontal price levels based on pivot points to highlight potential areas of supply and demand. It serves as a visual guide for technical analysis, allowing traders to monitor key price thresholds where reversals or breakouts may occur.

Usage

The Usage section focuses on how the indicator visualizes critical market levels. The script identifies "Pivot Highs" and "Pivot Lows" based on a user-defined window of surrounding bars. Once a pivot is confirmed, a horizontal line is extended forward to represent a potential resistance or support zone.

Traders typically use these levels to:

  • Identify potential price targets or areas of reversal.
  • Monitor breakouts when price closes above a resistance line.
  • Monitor breakdowns when price closes below a support line.

Due to the nature of pivot points, these lines are plotted with an offset. A pivot point can only be confirmed after a certain number of bars (defined by the "Right Bars" setting) have closed, meaning the levels appear on the chart with a slight delay to ensure the structural integrity of the high or low.

Details

The indicator utilizes the ta.pivothigh() and ta.pivotlow() functions to detect price extremes. A pivot high is defined when a bar's high is greater than the highs of X bars to its left and Y bars to its right. Conversely, a pivot low is defined when a bar's low is lower than the lows of the surrounding bars.

The horizontal levels are updated every time a new pivot is detected. To maintain visual clarity, the script uses a plot offset to align the start of the line with the actual peak or trough of the pivot, even though the calculation is finalized several bars later. Built-in alert conditions are also included to notify users when the closing price crosses these dynamically generated levels.

Settings

  • Left Bars: Determines the number of bars to the left of a potential pivot point required to confirm a local high or low. Increasing this value results in more significant, but fewer, support and resistance levels.
  • Right Bars: Determines the number of bars to the right of a potential pivot point required to confirm the level. Higher values increase the confirmation delay but ensure more stable levels.

FAQ

How do I interpret the delay in the lines appearing? The lines appear after the "Right Bars" count has been reached because the script must verify that no higher high or lower low has occurred within that window to confirm the pivot.

Can these levels be used for automated alerts? Yes, the script includes logic for breakout and breakdown alerts that trigger when the price closes beyond the established support or resistance levels.

How can I access the Support and Resistance 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.