PROTECTED SOURCE SCRIPT

DCA + Liquidation Levels

49
The indicator combines a Dollar-Cost Averaging (DCA) strategy after downtrends with liquidation level detection, providing comprehensive market analysis.

📈 Working Principle
1. DCA Strategy Foundation
EMA 50 and EMA 200 - used as primary trend indicators

EMA-CD Histogram - difference between EMA50 and EMA200 with signal line

BHD Levels - dynamic support/resistance levels based on volatility

2. DCA Entry Logic
pinescript
// Entry Conditions
entry_condition1 = nPastCandles > entryNumber * 24 * 30 // Monthly interval
entry_condition2 = emacd < 0 and hist < 0 and hist > hist[2] // Downtrend reversal
ENTRY_CONDITIONS = entry_condition1 and entry_condition2
Entry triggers when:

Specified time has passed since last entry (monthly intervals)

EMA-CD is negative but showing reversal signs (histogram increasing)

Market is emerging from downtrend

3. Price Zone Coloring System
pinescript
// BHD Unit Calculation
bhd_unit = ta.rma(high - low, 200) * 2
price_level = (close - ema200) / bhd_unit
Color Zones:

🔴 Red Zone: Level > 5 (Extreme Overbought)

🟠 Orange Zone: Level 4-5 (Strong Overbought)

🟡 Yellow Zone: Level 3-4 (Overbought)

🟢 Green Zone: Level 2-3 (Moderate Overbought)

🔵 Light Blue: Level 1-2 (Slightly Overbought)

🔵 Blue: Level 0-1 (Near EMA200)

🔵 Dark Blue: Level -1 to -4 (Oversold)

🔵 Extreme Blue: Level < -4 (Extreme Oversold)

4. Liquidation Levels Detection
pinescript
// Open Interest Delta Analysis
OI_delta = OI - nz(OI[1])
OI_delta_abs_MA = ta.sma(math.abs(OI_delta), maLength)
Liquidation Level Types:

Large Liquidation Level: OI Delta ≥ 3x MA

Middle Liquidation Level: OI Delta 2x-3x MA

Small Liquidation Level: OI Delta 1.2x-2x MA

Leverage Calculations:

5x, 10x, 25x, 50x, 100x leverage levels

Both long and short liquidation prices

⚙️ Technical Components
1. Moving Averages
EMA 50: Short-term trend direction

EMA 200: Long-term trend foundation

EMA-CD: Momentum and trend strength measurement

2. BHD Levels Calculation
pinescript
bhd_unit = ta.rma(high - low, 200) * 2
bhd_upper = ema200 + bhd_unit * N // Resistance levels
bhd_lower = ema200 - bhd_unit * N // Support levels
Where N = 1 to 5 for multiple levels

3. Open Interest Integration
Fetches Binance USDT perpetual contract OI data

Calculates OI changes to detect large position movements

Identifies potential liquidation clusters

🔔 Alert System
Zone Transition Alerts
Triggers: When price moves between different BHD zones

Customizable: Each zone alert can be enabled/disabled individually

Information: Includes exact level, price, and EMA200 value

Alert Types Available:
🔴 Red Zone Alert

🟠 Orange Zone Alert

🟡 Yellow Zone Alert

🟢 Green Zone Alert

🔵 Light Blue Zone Alert

🔵 Blue Zone Alert

🔵 Dark Blue Zone Alert

🔵 Extreme Blue Zone Alert

🎨 Visual Features
1. Candle Coloring
Real-time color coding based on price position relative to EMA200

Immediate visual identification of market conditions

2. Level Displays
EMA lines (50 & 200)

BHD support/resistance levels

Liquidation level lines with different styles based on significance

3. Entry Markers
Green upward labels below bars indicating DCA entry points

Numbered sequentially for tracking

📊 Input Parameters
DCA Settings
Start/End dates for backtesting

EMA periods customization

Liquidation Levels Settings
MA Length for OI Delta

Threshold multipliers for different liquidation levels

Display toggles for lines and histogram

Alert Settings
Individual zone alert enable/disable

Customizable sensitivity

🔧 Usage Recommendations
For DCA Strategy:
Enter positions at marked DCA points after downtrends

Use BHD levels for position sizing and take-profit targets

Monitor zone transitions for market condition changes

For Liquidation Analysis:
Watch for price approaches to liquidation levels

Use histogram for density of liquidation clusters

Combine with zone analysis for entry/exit timing

⚠️ Limitations
Data Dependency: Requires Binance OI data availability

Market Specific: Optimized for cryptocurrency markets

Timeframe: Works best on 1H+ timeframes for reliable signals

Volatility: BHD levels may need adjustment for different volatility regimes

🔄 Updates and Maintenance
Regular compatibility checks with TradingView updates

Performance optimization for different market conditions

User feedback incorporation for feature improvements

This indicator provides institutional-grade market analysis combined with systematic DCA strategy implementation, suitable for both manual trading and algorithmic strategy development.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.