How are candles analyzed in the volatility calculation?

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:

  1. The selected candles are split into two halves:

    • First half: older candles in the observation window
    • Second half: newer candles + the live price
  2. 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_pct to determine whether to hold or execute DCA.


๐Ÿ”น 4๏ธโƒฃ Why Candle Analysis Matters

Analyzing multiple candles instead of single points provides several advantages:

  1. Filters Noise: Single spikes or outliers do not falsely trigger the Volatility Gate
  2. Detects Sustained Momentum: Only real, continued moves are treated as โ€œexplosiveโ€
  3. Balances Responsiveness: Short enough window to react quickly, long enough to smooth random volatility
  4. 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:

  1. Collect the last N 1-minute candles
  2. Split them into first-half vs second-half averages
  3. Blend in live price for current conditions
  4. Compute smoothed movement to evaluate market momentum
  5. 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.

๐Ÿ“Ž Related Topics