OPEN-SOURCE SCRIPT

Support and Resistance with Buy/Sell Signals

217
Swing Highs and Lows:

The script identifies swing highs and lows using the ta.highest and ta.lowest functions over a user-defined swing_length period.

Swing highs are treated as resistance levels.

Swing lows are treated as support levels.

Buy Signal:

A buy signal is generated when the price closes above the resistance level (ta.crossover(close, swing_high)).

Sell Signal:

A sell signal is generated when the price closes below the support level (ta.crossunder(close, swing_low)).

Plotting:

Support and resistance levels are plotted on the chart.

Buy and sell signals are displayed as labels on the chart.

Background Highlighting:

The background is highlighted in green for buy signals and red for sell signals (optional).

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.