OPEN-SOURCE SCRIPT
Master Strategy: BTC W1 Mean Reversion [Institutional SOP]

Overview This is an institutional-grade Mean Reversion and Range Rotation strategy designed specifically for Bitcoin (BTC/USDT) Perpetual Futures. It operates on the philosophy that liquidity resides at the extremes of the previous week's range (Previous Week High/Low). The strategy looks for false breakouts (Sweeps) followed by a confirmed return to the range (Reclaim), targeting the weekly equilibrium (EQ).
Core Logic: The Deviation Play Unlike standard breakout strategies, this indicator hunts for trapped liquidity.
Weekly Levels (Fixed): It calculates PWH (Previous Week High) and PWL (Previous Week Low) based on confirmed, closed weekly data. These levels act as the "Box" for the current week.
The Sweep: We wait for price to pierce the PWH or PWL (taking liquidity/stops). The script uses a dynamic ATR-based threshold to filter out noise (micro-pokes).
The Reclaim (4H Close): A signal is generated ONLY if a 4H candle closes back inside the weekly range shortly after the sweep. This confirms rejection of higher/lower prices.
The Entry: The script suggests a Limit Order at the retested level (PWH/PWL) to maximize R:R.
Institutional Quality Filters ("Kill Switches") To prevent trading in unfavorable conditions, the script includes strict SOP (Standard Operating Procedure) filters:
Trend Filter (ADX): Blocks mean reversion signals if the daily trend is too strong (ADX > 25).
Expansion Filter: Blocks signals if price accepted levels outside the range for too long (prevents fighting a true breakout).
Weekly Range Filter: Filters out weeks that are statistically too tight (chop) or too wide (expansion).
Time Filter: A reclaim must happen within a set number of 4H bars after the sweep (default: 3).
Key Features
Zero Repainting: Logic is based strictly on closed candles ([1], [2], [3]).
State Machine Logic: Uses internal memory to track sweeps regardless of chart timeframe glitches.
Operational Dashboard: Displays current status, countdown to next decision candle (4H close), and exact parameters for the last valid signal (Entry, SL, TP).
Unified Alerting: A single "Any function call" alert handles both Long and Short scenarios dynamically.
Clean Visuals: Levels are plotted with line breaks to avoid visual clutter between weeks.
How to Use
Timeframe: Set your chart to 4H. This is crucial as the logic relies on 4H closes.
Signals: Wait for the "4H RECLAIM" label.
Execution: Place a Limit Order at the suggested Level (PWH/PWL).
Stop Loss: Use the calculated SL provided by the indicator (Swing extreme + ATR buffer).
Target: TP1 is always the EQ (Equilibrium/Mid-range).
Core Logic: The Deviation Play Unlike standard breakout strategies, this indicator hunts for trapped liquidity.
Weekly Levels (Fixed): It calculates PWH (Previous Week High) and PWL (Previous Week Low) based on confirmed, closed weekly data. These levels act as the "Box" for the current week.
The Sweep: We wait for price to pierce the PWH or PWL (taking liquidity/stops). The script uses a dynamic ATR-based threshold to filter out noise (micro-pokes).
The Reclaim (4H Close): A signal is generated ONLY if a 4H candle closes back inside the weekly range shortly after the sweep. This confirms rejection of higher/lower prices.
The Entry: The script suggests a Limit Order at the retested level (PWH/PWL) to maximize R:R.
Institutional Quality Filters ("Kill Switches") To prevent trading in unfavorable conditions, the script includes strict SOP (Standard Operating Procedure) filters:
Trend Filter (ADX): Blocks mean reversion signals if the daily trend is too strong (ADX > 25).
Expansion Filter: Blocks signals if price accepted levels outside the range for too long (prevents fighting a true breakout).
Weekly Range Filter: Filters out weeks that are statistically too tight (chop) or too wide (expansion).
Time Filter: A reclaim must happen within a set number of 4H bars after the sweep (default: 3).
Key Features
Zero Repainting: Logic is based strictly on closed candles ([1], [2], [3]).
State Machine Logic: Uses internal memory to track sweeps regardless of chart timeframe glitches.
Operational Dashboard: Displays current status, countdown to next decision candle (4H close), and exact parameters for the last valid signal (Entry, SL, TP).
Unified Alerting: A single "Any function call" alert handles both Long and Short scenarios dynamically.
Clean Visuals: Levels are plotted with line breaks to avoid visual clutter between weeks.
How to Use
Timeframe: Set your chart to 4H. This is crucial as the logic relies on 4H closes.
Signals: Wait for the "4H RECLAIM" label.
Execution: Place a Limit Order at the suggested Level (PWH/PWL).
Stop Loss: Use the calculated SL provided by the indicator (Swing extreme + ATR buffer).
Target: TP1 is always the EQ (Equilibrium/Mid-range).
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.