Spread Mean Reversion Strategy [SciQua]

Spread Mean Reversion Strategy [SciQua]
╰───────────────────────────────────────╯
This invite-only futures spread strategy applies a statistical mean reversion framework, executing limit orders exclusively at calculated Z-score thresholds for precise, rules-based entries and exits. It is designed for CME-style spreads and synthetic instruments with well-defined reversion tendencies.
╭────────────╮
Core Concept
╰────────────╯
The strategy calculates a rolling mean and standard deviation of a chosen spread or synthetic price series, then computes the Z-score to measure deviation from the mean in standard deviation units.
- Long entries trigger when Z crosses upward through a negative entry threshold (`-devEnter`). A buy limit is placed exactly at the price corresponding to that Z-score, optionally offset by a configurable tick amount.
- Short entries trigger when Z crosses downward through a positive entry threshold (`+devEnter`). A sell limit is placed at the corresponding threshold price, also with optional offset.
- Exits use the same threshold method, with an independent `Close Limit Offset` to fine-tune exit placement.
╭────────────╮
Key Features
╰────────────╯
- Persistence filter – Requires the Z-score to remain beyond threshold for a configurable number of bars before entry.
- Cooldown after exits – Prevents immediate re-entry to reduce over-trading.
- Daily and weekend flattening – Force-flattens positions via limit orders before exchange maintenance breaks and weekend closes.
- Auto-rollover detection with persistence – Detects when the second contract month’s daily volume exceeds the first for a set number of days, then blocks new entries (optional).
- Configurable tick offsets – Independently adjust entry and exit levels relative to threshold prices.
- Minimum spread width filter – Blocks trades when long/short entry thresholds are too close together.
- Contract multiplier override – Allows correct sizing for synthetic symbols where `syminfo.pointvalue` is incorrect or missing.
- Limit-only execution – All entries, exits, and forced-flat actions are executed with limit orders for price control.
╭────────────────────╮
Entry Blocking Rules
╰────────────────────╯
New trades are blocked:
- During daily maintenance break pre-windows
- During weekend close pre-windows
- After rollover triggers, if `Block After Roll` is enabled
╭────────────────────────╮
Intended Markets & Usage
╰────────────────────────╯
- Built for futures spreads and synthetic instruments, including calendar spreads.
- Performs best in markets with clear seasonal or statistical mean-reverting tendencies.
- Not designed for strongly trending, non-reverting markets.
╭──────────────────────────╮
Risk Management & Defaults
╰──────────────────────────╯
- Fixed default position size of 1 contract (qty calc function available for customization).
- Realistic commission and slippage assumptions pre-set.
- Pyramiding disabled by default.
- Default Z-score levels: Entry at ±2.0, Exit at ±0.5.
- Separate tick offset controls for entries and exits.
Note: This strategy is for research and backtesting purposes only. Past performance does not guarantee future results. All use is subject to explicit written permission from the author.
สคริปต์เฉพาะผู้ได้รับเชิญเท่านั้น
เฉพาะผู้ใช้ที่ได้รับการอนุมัติจากผู้เขียนเท่านั้นที่สามารถเข้าถึงสคริปต์นี้ได้ คุณจะต้องร้องขอและได้รับอนุญาตก่อนจึงจะสามารถใช้งานได้ โดยปกติจะได้รับอนุญาตหลังจากชำระเงินแล้ว สำหรับรายละเอียดเพิ่มเติม ทำตามคำแนะนำของผู้เขียนด้านล่างหรือติดต่อ JoshuaDanford โดยตรง
TradingView ไม่แนะนำให้ชำระเงินหรือใช้สคริปต์ เว้นแต่ว่าคุณจะเชื่อถือผู้เขียนสคริปต์และเข้าใจวิธีการทำงานของมัน คุณยังอาจพบทางเลือกของโอเพนซอร์ส แบบฟรีในสคริปต์ชุมชนของเรา
คำแนะนำของผู้เขียน
คำเตือน: โปรดอ่านคำแนะนำของเราสำหรับสคริปต์เฉพาะที่ได้รับเชิญเท่านั้น ก่อนที่จะขอสิทธิ์เข้าถึง
TradingView indicators, backtesting tools, weekly contests, and live market analysis.
Join free, compete, win, and stay updated at sciqua.com
คำจำกัดสิทธิ์ความรับผิดชอบ
สคริปต์เฉพาะผู้ได้รับเชิญเท่านั้น
เฉพาะผู้ใช้ที่ได้รับการอนุมัติจากผู้เขียนเท่านั้นที่สามารถเข้าถึงสคริปต์นี้ได้ คุณจะต้องร้องขอและได้รับอนุญาตก่อนจึงจะสามารถใช้งานได้ โดยปกติจะได้รับอนุญาตหลังจากชำระเงินแล้ว สำหรับรายละเอียดเพิ่มเติม ทำตามคำแนะนำของผู้เขียนด้านล่างหรือติดต่อ JoshuaDanford โดยตรง
TradingView ไม่แนะนำให้ชำระเงินหรือใช้สคริปต์ เว้นแต่ว่าคุณจะเชื่อถือผู้เขียนสคริปต์และเข้าใจวิธีการทำงานของมัน คุณยังอาจพบทางเลือกของโอเพนซอร์ส แบบฟรีในสคริปต์ชุมชนของเรา
คำแนะนำของผู้เขียน
คำเตือน: โปรดอ่านคำแนะนำของเราสำหรับสคริปต์เฉพาะที่ได้รับเชิญเท่านั้น ก่อนที่จะขอสิทธิ์เข้าถึง
TradingView indicators, backtesting tools, weekly contests, and live market analysis.
Join free, compete, win, and stay updated at sciqua.com