PROTECTED SOURCE SCRIPT
Consolidating Box with EMA

**Consolidating Box with EMA** automatically identifies tight consolidation zones near an EMA and draws a dotted box around the most recent valid range. It also displays key stats (range and candle count) in a small table.
---
### What it shows
* **Consolidation Box (dotted white border):**
* **Top:** Highest High within the detected range
* **Bottom:** Lowest Low within the detected range
* **Info Table (bottom-right):**
* **R:** Range in ATR units → `(BoxHigh - BoxLow) / ATR`
* **N:** Number of candles in the consolidation
> Only the **latest** consolidation box is displayed. The script removes the previous box/table on each last-bar update.
---
### How it works
On the latest bar, the script scans back up to **50 candles** and attempts to find a consolidation where:
* The overall High–Low range stays within a volatility threshold:
`Range <= ATR Multiplier × ATR`
* The consolidation is **near the EMA**, meaning at least one candle overlaps this EMA band:
`EMA ± (EMA Multiplier × ATR)`
* The range contains at least **Minimum Consolidation Candles**.
To be flexible across different volatility conditions, it iterates ATR thresholds from **ATR Multiplier Min** to **ATR Multiplier Max**, using **ATR Multiplier Step**, and stops at the first valid match.
---
### Inputs
**General**
* **Minimum Consolidation Candles:** Minimum number of candles required to qualify.
**ATR**
* **ATR Length:** ATR period used for volatility normalization.
* **ATR Multiplier Min / Max:** Tightness range used to search for consolidation.
* **ATR Multiplier Step:** Increment size while searching.
**EMA**
* **EMA Length:** EMA period used as the “mean” reference.
* **EMA Multiplier:** Width of the EMA proximity band in ATR units.
---
### Tips
* Lower **ATR Multiplier Max** → fewer but tighter boxes
* Increase **Minimum Consolidation Candles** → longer, more reliable consolidations
* Increase **EMA Multiplier** → allows boxes farther from the EMA band
---
---
### What it shows
* **Consolidation Box (dotted white border):**
* **Top:** Highest High within the detected range
* **Bottom:** Lowest Low within the detected range
* **Info Table (bottom-right):**
* **R:** Range in ATR units → `(BoxHigh - BoxLow) / ATR`
* **N:** Number of candles in the consolidation
> Only the **latest** consolidation box is displayed. The script removes the previous box/table on each last-bar update.
---
### How it works
On the latest bar, the script scans back up to **50 candles** and attempts to find a consolidation where:
* The overall High–Low range stays within a volatility threshold:
`Range <= ATR Multiplier × ATR`
* The consolidation is **near the EMA**, meaning at least one candle overlaps this EMA band:
`EMA ± (EMA Multiplier × ATR)`
* The range contains at least **Minimum Consolidation Candles**.
To be flexible across different volatility conditions, it iterates ATR thresholds from **ATR Multiplier Min** to **ATR Multiplier Max**, using **ATR Multiplier Step**, and stops at the first valid match.
---
### Inputs
**General**
* **Minimum Consolidation Candles:** Minimum number of candles required to qualify.
**ATR**
* **ATR Length:** ATR period used for volatility normalization.
* **ATR Multiplier Min / Max:** Tightness range used to search for consolidation.
* **ATR Multiplier Step:** Increment size while searching.
**EMA**
* **EMA Length:** EMA period used as the “mean” reference.
* **EMA Multiplier:** Width of the EMA proximity band in ATR units.
---
### Tips
* Lower **ATR Multiplier Max** → fewer but tighter boxes
* Increase **Minimum Consolidation Candles** → longer, more reliable consolidations
* Increase **EMA Multiplier** → allows boxes farther from the EMA band
---
保護スクリプト
このスクリプトのソースコードは非公開で投稿されています。 ただし、制限なく自由に使用できます – 詳細はこちらでご確認ください。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。
保護スクリプト
このスクリプトのソースコードは非公開で投稿されています。 ただし、制限なく自由に使用できます – 詳細はこちらでご確認ください。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。