OPEN-SOURCE SCRIPT
Telah dikemas kini

Combined Support & Resistance Indicators

253
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.
Nota Keluaran
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.
Nota Keluaran
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).

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.