regime_window

๐Ÿฆ‰ AthenaAI is an AI-powered ensemble machine-learning trading bot for PocketOption, built on BinaryOptionsToolsV2 โ†’ Get it on GitLab
๐Ÿ’ฌ Need help? Join the Chipa Discord ยท โšก Go no-code with ChipaEditor

How many of the most recent candles the regime detector analyzes to classify the market as trending up, trending down, ranging, or volatile.

This field has no environment variable โ€” to change it, edit the default in src/config.py or construct BotConfig yourself.

Typeint (candles)
Default30
FieldBotConfig.regime_window
Consumed insrc/bot.py (AITradingBot._trade_loop) โ†’ src/core/regime.py (RegimeDetector.detect)

What it does

Each trade-loop iteration calls:

regime = self.regime_detector.detect(candle_list, self.cfg.regime_window)

RegimeDetector.detect(candles, window) in src/core/regime.py:

  1. If fewer than window candles are available, returns Regime.RANGING (a safe default).
  2. Takes the last window closes, computes per-candle returns, then:
    • vol = standard deviation of returns,
    • rel_trend = linear-regression slope of the closes, normalized by the last price and multiplied by window.
  3. Classifies with v6 thresholds calibrated for 1-minute EURUSD:
    • vol > 0.0008 โ†’ VOLATILE
    • rel_trend > 0.0003 โ†’ TRENDING_UP
    • rel_trend < -0.0003 โ†’ TRENDING_DOWN
    • otherwise โ†’ RANGING

The regime label is used for the skip_volatile_regime gate, fed to the AI expiry selector, checked by the AdaptiveStrategy (which blocks regimes with a live win rate below 48%), logged with every trade, and stored in the trade journal. Periodic model snapshots (every 10 trades) call detect without the window argument, using the function default of 30.

Valid values

Any positive integer up to lookback. Smaller windows (15โ€“20) react faster to regime shifts but flip-flop more; larger windows (50+) are more stable but slower. Note the volatility/trend thresholds are hard-coded for the default 30-candle window on 1-minute data โ€” changing the window (or timeframe) shifts what those thresholds mean, and the trend term scales with window.

Examples

# src/config.py
regime_window: int = 50                 # slower, steadier regime classification
from src.config import BotConfig
cfg = BotConfig(ssid="...", regime_window=50)

Interactions

  • skip_volatile_regime โ€” hard gate on the resulting label.
  • lookback โ€” the candle buffer must hold at least regime_window candles or detection always returns ranging.
  • Expiry selection uses the regime as an input.

See also

๐Ÿ’ฌ Unsure how this interacts with the rest of the configuration? Ask in the Chipa Discord โ€” or prototype strategies no-code with ChipaEditor.