Sideways + Buy + Sell Detection

---
### ๐ **Script Purpose**
This script is designed to detect three different types of market conditions:
1. **Sideways (range-bound) market** โ useful for non-directional strategies like strangles or straddles.
2. **Bullish trend** โ provides a signal to consider buying.
3. **Bearish trend** โ provides a signal to consider selling.
---
### ๐ง **Indicators Used**
* **RSI (Relative Strength Index)**: Measures market momentum. It's used to determine whether the market is in a bullish, bearish, or neutral zone.
* **ADX (Average Directional Index)** along with **DI+ and DI-**: Measures the strength and direction of a trend.
* **MACD (Moving Average Convergence Divergence)**: Confirms momentum and trend direction based on moving averages.
---
### ๐ช **Sideways Market Signal**
A sideways (non-trending) signal is shown when:
* RSI indicates the market is neither overbought nor oversold (in the middle range).
* ADX shows weak trend strength.
* The ADX value is lower than both DI+ and DI-, suggesting indecision or lack of clear trend.
A purple label appears below the bar when this condition is met.
---
### ๐ฉ **Buy Signal**
A buy signal is generated when:
* RSI shows strong upward momentum.
* ADX confirms there is a strong trend.
* MACD confirms bullish conditions with both the MACD and signal lines above zero and in the correct crossover direction.
A green label appears below the bar when these bullish conditions align.
---
### ๐ฅ **Sell Signal**
A sell signal appears when:
* RSI shows strong downward momentum.
* ADX confirms a strong trend.
* MACD confirms bearish conditions, with both MACD and signal lines below zero and in the correct crossover direction.
A red label appears โ currently also plotted below the bar (which you may want to move above the bar for better clarity).
---
### โ **Use Case**
This script is suitable for:
* Deciding when to deploy **strangle/straddle** strategies in sideways markets.
* Identifying strong **bullish or bearish trends** for directional trades.
* Filtering out weak or indecisive conditions.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda โ ketahui lebih lanjut di sini.
Penafian
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda โ ketahui lebih lanjut di sini.