Strategies
BTC OKX 4H Donchian-Midline Regression-Slope Acceleration: Enter on ATR-Normalised Slope Breaking +/-1 ATR, Exit on 3-Bar Slope Deceleration or Chandelier Stop, Explicit Flat State (BTCUSDT.OKX 4H, pure OHLCV, long-short, single leg)
Outcome: Abandoned
BtcOkxDonchianMidlineSlopeAccelLS
Outcome Summary
BtcOkxDonchianMidlineSlopeAccelLS reworked a high-turnover FMZ slope-flip strategy into a thresholded trend strategy on OKX BTC 4H bars. It entered on ATR-normalised midline-slope acceleration, exited on deceleration or a chandelier stop, and stayed flat in between. The hypothesis stressed O(1) per-bar indicators because of recent sandbox timeouts, but after 3 iterations the code still failed Layer 3 verification: the smoke test exceeded the 300s limit on a ~20,000-bar window. Backtest review, optimization, analyst review and risk review were never reached, so there is no performance data.
Hypothesis
Iteration 3. The Layer-1 syntax error at line 1 came from a malformed code payload in iteration 2: its outbox file is gone and whatever reached the verifier was not the Python class. This resubmits the full class source. It also addresses the iteration-1 Layer-3 timeout. HHV/LLV now use O(1)-amortised monotonic deques instead of max()/min() over the window each bar, and the SMA uses a running sum. The OLS slope stays a closed form over a fixed 35-element deque, so per-bar cost does not depend on the length of the backtest (~14.6k 4H bars). Signal, entry, exit and sizing logic are unchanged. The code clamps parameters, and the matching ranges are declared in _param_bounds.
verification_loop: sandbox_timeout: Verification failed (Layer 3 — sandbox backtest): smoke test exceeded the 300s wall-clock limit on a ~20000-bar window (2400 days of BTCUSDT.OKX-4-HOUR-LAST-EXTERNAL). This almost always means per-bar work that scales with history — e.g. rescanning the full funding/supplementary series, or rebuilding a list and calling min()/sorted() inside calculate_signal()/on_bar() on every bar. Precompute sorted timestamp arrays ONCE in __init__ and use bisect, or cache lookups keyed by timestamp, so per-bar cost is O(log n) not O(n).
Implementation
BTCUSDT.OKX 4H long-short. Donchian(35) midline -> SMA(5) -> 35-bar OLS slope, normalised by ATR(35) into S = ATRs travelled across the window (continuous signal). Enter long/short when S crosses +/-1.0 from flat; exit on 3 consecutive bars of S moving toward zero (deceleration) or a 3-ATR chandelier stop from the post-entry extreme. Flat state between legs. Risk-based sizing: 1.5% equity risk / max(3*ATR/price, 1%), capped at 1x equity * leverage.
Verification Results
sandbox_timeout: Verification failed (Layer 3 — sandbox backtest): smoke test exceeded the 300s wall-clock limit on a ~20000-bar window (2400 days of BTCUSDT.OKX-4-HOUR-LAST-EXTERNAL). This almost always means per-bar work that scales with history — e.g. rescanning the full funding/supplementary series, or rebuilding a list and calling min()/sorted() inside calculate_signal()/on_bar() on every bar. Precompute sorted timestamp arrays ONCE in __init__ and use bisect, or cache lookups keyed by timestamp, so per-bar cost is O(log n) not O(n).
Iteration History
Verification failed (Layer 1 — static analysis): - Syntax error: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers (<unknown>, line 1) (line 1)
Outcome Summary
A design meant to be O(1) per bar can still time out in the sandbox. Before submitting, profile the per-bar indicator update over a 20k-bar window (for example the O(slope_len) OLS loop and the deque maintenance), because repeated sandbox timeouts end a strategy before it produces any backtest evidence.
After 3 iterations it was abandoned in a verification loop. Layer 3 (the sandbox backtest) failed with a sandbox timeout: the smoke test ran past the 300s wall-clock limit on a ~20,000-bar (2,400-day) BTCUSDT.OKX 4H window.
A long-short trend strategy on BTCUSDT.OKX 4H bars. It entered when the ATR-normalised OLS slope of a smoothed 35-bar Donchian midline crossed +/-1 ATR, and exited after 3 bars of slope deceleration or a 3-ATR chandelier stop, staying flat in between. It was rebuilt from the FMZ 'speed-rate' strategy, which flipped position on nearly every bar.
There are no performance numbers. The backtest report is empty and optimization never ran, so there is no return, Sharpe or trade count.
Analysis
定量分型速率交易策略
Backtest and paper results are hypothetical. Trading involves risk of loss.