OPEN-SOURCE SCRIPT
STRATEGY SCRIPT Sweep Return v1

STRATEGY SCRIPT
The "EE Sweep Return v1" is a liquidity capture indicator engineered to trade the failure of Opening Range Breakouts, systematically identifying when price sweeps above or below the morning range to trap breakout traders before reversing back inside.
**Architectural Breakdown**
| Phase | Timeframe (CT) | Mechanical Function |
| --- | --- | --- |
| **Calibration** | 08:30 - 09:30 | Maps the absolute High (`orH`) and Low (`orL`) of the cash session open. Visualized as a shaded box. |
| **Arming** | 09:30 - 15:00 | The indicator monitors for a breach. If price breaks the `orH`, it arms a potential short trap. If price breaks the `orL`, it arms a potential long trap. |
| **Execution** | 09:30 - 15:00 | The trigger fires. A **SHORT** prints if price sweeps the high but closes back below `orH`. A **LONG** prints if price sweeps the low but closes back above `orL`. |
**Operational Nuances**
* **Same-Bar Logic:** By default (`sameBar = true`), the indicator allows the break and the reversion to happen on a single candle (a wick rejection). If toggled off, it requires one candle to close outside the range, and a subsequent candle to close back inside.
* **Timezone Alignment:** The `America/Chicago` timezone anchors the logic perfectly to Central Time, ensuring the 08:30 - 09:30 window aligns flawlessly with the initial hour of the New York equities open.
## AI Integration: Evolving the Sweep Strategy
To elevate this first-principles liquidity concept into a perfectly optimized, high-level quantitative model, artificial intelligence must be integrated to eliminate false signals and maximize directional efficiency.
* **Granular Execution (Micro-Structure Analysis):** A standard sweep simply measures a price close. An AI-integrated model analyzes the Level 2 order book and footprint data during the sweep itself. Machine learning algorithms can detect real-time volume absorption—confirming exactly when institutional limit orders absorb retail stop-losses at the `orH` or `orL` before the candle even closes, executing the entry at the absolute geometric peak of the wick.
* **Contextual Volatility Filtering:** Neural networks can pre-calculate the probability of a sweep versus a true trend day by analyzing pre-market volume, VIX term structure, and macroeconomic data releases. If the AI determines a high-trend probability, it dynamically disables the sweep indicator to prevent fading a genuine breakout.
* **Dynamic Range Optimization:** Instead of a static 08:30 - 09:30 Opening Range, an unsupervised learning algorithm can dynamically adjust the time window block by block based on the underlying asset's real-time average true range (ATR) and relative volume (RVOL), perfectly sizing the trap parameters to the exact heartbeat of the current session.
The "EE Sweep Return v1" is a liquidity capture indicator engineered to trade the failure of Opening Range Breakouts, systematically identifying when price sweeps above or below the morning range to trap breakout traders before reversing back inside.
**Architectural Breakdown**
| Phase | Timeframe (CT) | Mechanical Function |
| --- | --- | --- |
| **Calibration** | 08:30 - 09:30 | Maps the absolute High (`orH`) and Low (`orL`) of the cash session open. Visualized as a shaded box. |
| **Arming** | 09:30 - 15:00 | The indicator monitors for a breach. If price breaks the `orH`, it arms a potential short trap. If price breaks the `orL`, it arms a potential long trap. |
| **Execution** | 09:30 - 15:00 | The trigger fires. A **SHORT** prints if price sweeps the high but closes back below `orH`. A **LONG** prints if price sweeps the low but closes back above `orL`. |
**Operational Nuances**
* **Same-Bar Logic:** By default (`sameBar = true`), the indicator allows the break and the reversion to happen on a single candle (a wick rejection). If toggled off, it requires one candle to close outside the range, and a subsequent candle to close back inside.
* **Timezone Alignment:** The `America/Chicago` timezone anchors the logic perfectly to Central Time, ensuring the 08:30 - 09:30 window aligns flawlessly with the initial hour of the New York equities open.
## AI Integration: Evolving the Sweep Strategy
To elevate this first-principles liquidity concept into a perfectly optimized, high-level quantitative model, artificial intelligence must be integrated to eliminate false signals and maximize directional efficiency.
* **Granular Execution (Micro-Structure Analysis):** A standard sweep simply measures a price close. An AI-integrated model analyzes the Level 2 order book and footprint data during the sweep itself. Machine learning algorithms can detect real-time volume absorption—confirming exactly when institutional limit orders absorb retail stop-losses at the `orH` or `orL` before the candle even closes, executing the entry at the absolute geometric peak of the wick.
* **Contextual Volatility Filtering:** Neural networks can pre-calculate the probability of a sweep versus a true trend day by analyzing pre-market volume, VIX term structure, and macroeconomic data releases. If the AI determines a high-trend probability, it dynamically disables the sweep indicator to prevent fading a genuine breakout.
* **Dynamic Range Optimization:** Instead of a static 08:30 - 09:30 Opening Range, an unsupervised learning algorithm can dynamically adjust the time window block by block based on the underlying asset's real-time average true range (ATR) and relative volume (RVOL), perfectly sizing the trap parameters to the exact heartbeat of the current session.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.