In the Volatility Gate, candles are the building blocks used to measure market momentum. The system does not rely on raw price deviation alone; instead, it analyzes a series of recent 1-minute candles to calculate smoothed movement, which determines whether DCA orders are safe to place.
🔹 1️⃣ Candle Selection
- The Volatility Gate uses recent 1-minute candles, configurable via
candles_to_analyze(default: 20) - Only the most recent candles are included, forming a rolling observation window
- Each candle contributes its mid-price:
mid_price = (high + low) / 2
This ensures that the calculation considers the full range of each candle rather than just opening or closing prices, giving a more balanced view of market momentum.
🔹 2️⃣ Splitting Candles for Smoothed Movement
To reduce noise and capture directional momentum:
The selected candles are split into two halves:
- First half: older candles in the observation window
- Second half: newer candles + the live price
Compute the average mid-price for each half:
first_avg = average(mid_price of candles 1 – N/2)
second_avg = average(mid_price of candles N/2+1 – N-1 + live_price)
- This comparison reveals momentum acceleration between the older and newer periods
- Using the live price in the second half ensures real-time responsiveness
🔹 3️⃣ Smoothed Movement Calculation
After splitting and averaging:
smoothed_movement = ((second_avg - first_avg) / first_avg) × 100
Long trades: adverse movement = -smoothed_movement (falling price is bad)
Short trades: adverse movement = +smoothed_movement (rising price is bad)
This smoothed movement is then compared against
explosive_threshold_pctto determine whether to hold or execute DCA.
🔹 4️⃣ Why Candle Analysis Matters
Analyzing multiple candles instead of single points provides several advantages:
- Filters Noise: Single spikes or outliers do not falsely trigger the Volatility Gate
- Detects Sustained Momentum: Only real, continued moves are treated as “explosive”
- Balances Responsiveness: Short enough window to react quickly, long enough to smooth random volatility
- Enhances Safety: Reduces the risk of “catching falling knives” by ignoring short-lived volatility
🔹 5️⃣ Example
Observation window: last 20 candles
First half (candles 1–10) average mid-price = $98
Second half (candles 11–19 + live price) average mid-price = $94
Smoothed movement: -4.08%
Explosive threshold = 3%
DCA decision: HELD (adverse movement > threshold)
By analyzing the candle averages rather than single price points, the bot identifies true explosive moves rather than reacting to noise.
🔹 6️⃣ Tuning Candle Analysis
- Candles to analyze: 15–25 recommended; more candles → smoother signal, slower reaction
- Shorter windows: more sensitive to sudden moves but may trigger false holds
- Longer windows: more conservative, fewer false positives, slower execution
Adjust candles_to_analyze based on:
- Symbol volatility
- Asset type (BTC/ETH vs MEME coins)
- Desired balance between safety and responsiveness
🔹 7️⃣ Summary
Candle analysis in Volatility Gate works as follows:
- Collect the last N 1-minute candles
- Split them into first-half vs second-half averages
- Blend in live price for current conditions
- Compute smoothed movement to evaluate market momentum
- Use this signal to hold or execute DCA orders safely
This approach allows the bot to act like a professional trader — reacting to sustained trends while ignoring short-term noise, giving institutional-grade DCA protection.