OPEN-SOURCE SCRIPT

SufianBD 2.0

1. Purpose of the Script
The script combines the MACD (Moving Average Convergence Divergence) and ADX (Average Directional Index) to generate buy and sell signals:

MACD helps identify momentum changes in price.
ADX ensures signals are only generated when the trend is strong enough.
It visually plots these signals as green "Buy" markers below the candles and red "Sell" markers above the candles. It also highlights the background when the trend is strong.

2. Inputs
The script uses user-defined parameters to customize the behavior of MACD and ADX:

Short EMA & Long EMA (12, 26):
The two EMAs used to calculate the MACD line.
Signal Length (9):
The smoothing length for the MACD signal line.
ADX Period (14):
The period used to calculate the ADX.
ADX Smoothing (14):
Smooths the ADX calculation.
ADX Threshold (20):
Defines the minimum ADX value for a "strong trend." Signals are only valid if the ADX is above this threshold.
3. Calculations
MACD (Momentum Detection)
macdLine: The difference between the short EMA and long EMA. It shows the momentum of price movement.
signalLine: A smoothed version of the MACD line, acting as a signal filter.
histogram: The difference between macdLine and signalLine, showing the strength of momentum.
ADX (Trend Strength Detection)
The ADX indicator measures the strength of a trend:
diPlus and diMinus: Show bullish and bearish directional movement.
adxValue: The ADX value determines whether the trend is strong enough to trade.
4. Signal Logic
The script generates buy and sell signals based on MACD and ADX:

Buy Signal:
Occurs when the MACD line crosses above the signal line (bullish crossover) and the ADX value is greater than the threshold (indicating a strong trend).
Sell Signal:
Occurs when the MACD line crosses below the signal line (bearish crossover) and the ADX value is greater than the threshold.
5. Visual Elements
Buy/Sell Signal Markers
Buy Signal:
Plotted as a green upward arrow (labelup) below the price bars.
Sell Signal:
Plotted as a red downward arrow (labeldown) above the price bars.
Background Highlight
When the ADX value exceeds the threshold (indicating a strong trend), the background is highlighted in blue.
6. Practical Use
This script is designed for traders looking to:

Identify optimal buy and sell opportunities during strong trends.
Filter out weak trends or sideways markets to avoid false signals.
Combine momentum (MACD) and trend strength (ADX) into a single strategy.
educational

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明