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.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.
Declinazione di responsabilità
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.