OPEN-SOURCE SCRIPT
已更新 Combined Support & Resistance Indicators

Pivot Points Calculation:
The script calculates the Pivot Point as the average of the high price (high), low price (low), and closing price (close) of the current bar.
The Pivot Point is plotted on the chart as a red line.
Support and Resistance Levels:
The Support Level is calculated as the lowest price over the last lookback bars.
The Resistance Level is calculated as the highest price over the last lookback bars.
These levels are displayed on the chart using horizontal lines: green for support and red for resistance.
Momentum Indicators:
RSI (Relative Strength Index): A momentum oscillator calculated based on the closing price over the last 14 bars. It is plotted as a yellow line.
MACD (Moving Average Convergence Divergence): An indicator consisting of the MACD line (blue) and the signal line (orange). It is calculated based on the closing price.
Moving Averages:
SMA 20: A simple moving average over the last 20 bars. It is plotted as a green line.
SMA 50: A simple moving average over the last 50 bars. It is plotted as a red line.
Dynamic Levels Drawing:
Instead of using hline (which does not support dynamic values), the script uses line.new to draw dynamic support and resistance levels. These lines are updated on each bar.
The script calculates the Pivot Point as the average of the high price (high), low price (low), and closing price (close) of the current bar.
The Pivot Point is plotted on the chart as a red line.
Support and Resistance Levels:
The Support Level is calculated as the lowest price over the last lookback bars.
The Resistance Level is calculated as the highest price over the last lookback bars.
These levels are displayed on the chart using horizontal lines: green for support and red for resistance.
Momentum Indicators:
RSI (Relative Strength Index): A momentum oscillator calculated based on the closing price over the last 14 bars. It is plotted as a yellow line.
MACD (Moving Average Convergence Divergence): An indicator consisting of the MACD line (blue) and the signal line (orange). It is calculated based on the closing price.
Moving Averages:
SMA 20: A simple moving average over the last 20 bars. It is plotted as a green line.
SMA 50: A simple moving average over the last 50 bars. It is plotted as a red line.
Dynamic Levels Drawing:
Instead of using hline (which does not support dynamic values), the script uses line.new to draw dynamic support and resistance levels. These lines are updated on each bar.
版本注释
Pivot Points Calculation:The script calculates the Pivot Point as the average of the high price (high), low price (low), and closing price (close) of the current bar.
The Pivot Point is plotted on the chart as a red line.
Support and Resistance Levels:
The Support Level is calculated as the lowest price over the last lookback bars.
The Resistance Level is calculated as the highest price over the last lookback bars.
These levels are displayed on the chart using horizontal lines: green for support and red for resistance.
RSI (Relative Strength Index) Indicator:
A momentum oscillator calculated based on the closing price over the last rsiLength bars.
It is plotted as a yellow line.
MACD (Moving Average Convergence Divergence) Indicator:
An indicator consisting of the MACD line (blue) and the signal line (orange).
It is calculated based on the closing price with reduced periods for faster reaction.
Exponential Moving Averages (EMA):
EMA 10: An exponential moving average over the last 10 bars. It is plotted as a green line.
EMA 20: An exponential moving average over the last 20 bars. It is plotted as a red line.
ATR (Average True Range) Indicator:
A volatility indicator calculated over the last atrLength bars.
It is plotted as a purple line.
Candlestick Patterns (Price Action):
Bullish Pin Bar: Forms when the close is above the open and above the previous bar's high, and the open is below the previous bar's low.
Bearish Pin Bar: Forms when the close is below the open and below the previous bar's low, and the open is above the previous bar's high.
Bullish Engulfing: Forms when the current candle fully engulfs the previous bearish candle.
Bearish Engulfing: Forms when the current candle fully engulfs the previous bullish candle.
Trend Filters:
Uptrend: Determined when EMA 10 is above EMA 20.
Downtrend: Determined when EMA 10 is below EMA 20.
Conditions for Longs (Buy):
Price is above the Pivot Point.
Price is above the Support Level.
RSI is above 50.
MACD line is above the signal line.
Uptrend (EMA 10 > EMA 20).
ATR is above its average value.
Volume is above its average value.
Presence of a bullish pin bar or bullish engulfing.
Conditions for Shorts (Sell):
Price is below the Pivot Point.
Price is below the Resistance Level.
RSI is below 50.
MACD line is below the signal line.
Downtrend (EMA 10 < EMA 20).
ATR is above its average value.
Volume is above its average value.
Presence of a bearish pin bar or bearish engulfing.
Alerts and Visualization:
Alerts for longs and shorts.
"BUY" and "SELL" labels on the chart.
Background highlighting for signals.
版本注释
1. Settings Parameters:Level Period (lookback): Number of bars to calculate support/resistance levels.
ATR Period (atrLength): Period for the Average True Range (ATR) volatility indicator.
Volume Filter (useVolume): Enables/disables volume confirmation for signals.
EMA Fast (emaFast): Period for the fast Exponential Moving Average (EMA).
EMA Slow (emaSlow): Period for the slow EMA to filter long-term trends.
ADX Threshold (adxThreshold): Minimum ADX value to confirm a strong trend.
Price Distance (%) (priceDistance): Maximum allowed deviation from support/resistance levels.
2. Support/Resistance Levels:
Calculation:
Support: Lowest price over lookback bars (ta.lowest).
Resistance: Highest price over lookback bars (ta.highest).
Visualization: Levels are plotted as green (support) and red (resistance) lines.
3. Moving Averages (EMA):
EMA Fast (emaFastLine): Tracks short-term trends.
EMA Slow (emaSlowLine): Identifies long-term trends.
Trend Conditions:
Uptrend: EMA Fast > EMA Slow.
Downtrend: EMA Fast < EMA Slow.
4. Candlestick Patterns (Pin Bars):
Bullish Pin Bar (bullishPinBar):
Green candle (close > open).
Body twice the size of the upper shadow: (close - open) > 2 * (high - close).
Bearish Pin Bar (bearishPinBar):
Red candle (close < open).
Body twice the size of the lower shadow: (open - close) > 2 * (close - low).
5. ADX Indicator:
Purpose: Measures trend strength.
Condition: Signals are generated if ADX > adxThreshold (default: 20).
6. Price Distance Filter:
Rule: Price must be within priceDistance% of the support/resistance level.
Formula: math.abs(close - level) / level * 100 <= priceDistance.
7. Volume Filter:
Rule: Volume must exceed the 10-bar average by 50% (if enabled).
8. Entry Conditions:
Long (longCondition):
Price near support.
Support breakout.
Bullish pin bar.
Uptrend (EMA Fast > EMA Slow).
Strong trend (ADX > threshold).
High volatility (ATR > average).
High volume (optional).
Short (shortCondition):
Price near resistance.
Resistance breakout.
Bearish pin bar.
Downtrend (EMA Fast < EMA Slow).
Strong trend (ADX > threshold).
High volatility (ATR > average).
High volume (optional).
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。