Zone Flow S/R Strategy by Awab_Hassan
By Awab_Hassan
Performance Metrics
- Author: Awab_Hassan
- Symbol: OANDA:XAUUSD
- Timeframe: 15 minutes
- Win Rate: 37.1%
- Profit Factor: 1.561
Description
Zone Flow S/R Strategy📌 Strategy OverviewZone Flow is a multi‑timeframe support/resistance strategy that uses dynamic pivot‑derived zones to identify high‑probability reversal and breakout setups.Unlike static support/resistance lines, this 9‑level zone system (R4–R1, P, S1–S4) automatically adapts to market structure changes at each new period (Daily/Weekly/Monthly). Each zone has a configurable width (Percentage, ATR, or Fixed) to account for volatility, and a breakout threshold to filter out minor wicks.# Unique Synergy Most pivot strategies treat levels as static lines, leading to false breakouts. Most engulfing strategies ignore the bigger picture, catching falling knives. This strategy solves both problems by combining these components in a specific sequence:1- Dynamic Zones + Gap State Machine (The Context)Instead of just drawing lines, we create zones (R1-R4, P, S1-S4) with adaptive width. More importantly, the Gap State Machine tracks which gap price sits in (e.g., between R1 and Pivot). This tells us exactly where we are in the market structure. If price moves from upper Gap to lower Gap, the strategy instantly switches sentiment from Bullish to Bearish.- Why this matters: It prevents the strategy from trading blindly; it only trades when price is transitioning between structural levels, and price retrace to the zone drastically reducing false signals in the middle of nowhere.2- Pin Bar Sweep + Engulfing Combo (The Momentum Trigger)A standard pin bar alone is a weak reversal signal. A standard engulfing pattern alone is common. However, when a Pin Bar sweeps the N-bar high/low (proving a breakout attempt failed) and is immediately followed by an Engulfing pattern on the next candle, this combo represents a "double confirmation" of exhaustion.Crucially, this specific combo overrides the EMA confirmation. - Why this matters: Strong momentum sweeps often happen against the short-term EMA trend. By allowing this specific combo to bypass the EMA, the strategy captures powerful reversals that pure trend-following strategies miss.3- Dynamic Zone Width (The Volatility Adaptation)Instead of using fixed support/resistance, the zone width changes based on the selected Period's ATR or Percentage. - Why this matters: This ensures the strategy scales perfectly across any asset (Gold, Crypto, Forex) without manual width adjustments, making it robust across different volatility regimes.4- Selective Zone Activation (The Manual Override)Unlike standard pivot systems that force trades on every level, the Zone Selection inputs allow users to disable specific zones (e.g., turn off R3 if price often fakes out there or turn off S4 market is always get exhausted lower probability trade). - Why this matters: This turns the strategy from a rigid algorithm into a customizable framework where the user can apply their own discretion based on historical price behavior.5. Hierarchical EMA Architecture (The Structural Governor)This strategy does not treat all EMAs equally. It uses a two-tier EMA system with a strict hierarchy:Lower TF EMA (Optional & Overrideable): The Lower TF EMA on the current timeframe acts as a micro-trend filter. However, as explained above, the Pin Bar Sweep + Engulfing Combo can override this filter. Why? Because strong institutional reversals often happen against the short-term trend, and we want to capture them.Higher TF EMA (Absolute & Non-Negotiable): Higher TF EMA on the selected Higher Timeframe acts as an "Absolute Structural Governor." Unlike the lower EMA, this filter cannot be overridden by any pattern.For Long entries: Price must be above this HTF EMA.For Short entries: Price must be below this HTF EMA.Most strategies either ignore the HTF entirely. By making the HTF EMA absolute and the LTF EMA overrideable, this strategy achieves the perfect balance:The HTF EMA prevents catastrophic drawdowns by keeping you on the right side of the bigger trend.The LTF EMA override allows you to catch sharp, high-probability reversals within that trend without being delayed by a slow-moving micro-filter.6. Optional Risk Architecture (The Management Layer)The strategy includes a built-in partial-take-profit and breakeven module. By default, this module is disabled to provide a clean, straightforward 1:3 risk-reward backtest without the complexity of multiple exit orders.This default setting allows users to evaluate the core entry logic (zones + patterns) without interference from partial exits.However, for traders who want to reduce psychological pressure or manage Gold's notorious retracements, they can enable Allow Breakeven and Allow Partial TP. When activated, the strategy closes a percentage of the position (e.g., 50%) at a lower R:R threshold (TP1) and moves the remaining position to breakeven—locking in early profits while letting the rest of the trade run.# Zone CalculationThe strategy calculates 9 zones using a modified pivot point formula from the selected period (Daily, Weekly, Monthly, Quarterly, Yearly):The pivot formula can be one of 5 methods: Classic, Fibonacci, Woodie, Camarilla, or DM.The Classic Pivot (shown below) is the most widely used and serves as the default:Pivot (P) = (H + L + C) / 3R1 = (2 × P) – LS1 = (2 × P) – HR2 = P + (H – L)S2 = P – (H – L)(R3, R4, S3, S4 are logical extensions of this same principle)Additional Methods (Briefly Explained):Fibonacci: Uses the golden ratio multipliers (0.382, 0.618, 1.000, 1.618) to place support/resistance levels between the pivot and the high/low range.Woodie: Gives extra weight to the closing price (Formula: P = (H + L + 2C) / 4), making it more sensitive to the current session's momentum.Camarilla: Uses multipliers based on the previous range to place levels very close to the current price, ideal for range-bound trading and scalping.DM: Adjusts the pivot formula conditionally based on whether the close was higher or lower than the open, making it adaptive to daily sentiment.From these, the strategy derives:- 4 Resistance Zones (R4, R3, R2, R1) – above the pivot- 1 Pivot Zone (P)- 4 Support Zones (S1, S2, S3, S4) – below the pivotEach zone is expanded by a Zone Width to create a buffer, making the levels more practical.# Zone Width CalculationThree modes:- Percentage – zone width as a percentage of current price - ATR Multiplier – width = ATR × Multiplier - Fixed – fixed price distance # Gap Index Mapping (0–9):Gap 0 – Above R4 → Aggressive (no trades)Gap 1 – Between R4 and R3 → Bearish near R4, Bullish near R3Gap 2 – Between R3 and R2 → Bearish near R3, Bullish near R2Gap 3 – Between R2 and R1 → Bearish near R2, Bullish near R1Gap 4 – Between R1 and Pivot → Bearish near R1, Bullish near PivotGap 5 – Between Pivot and S1 → Bearish near Pivot, Bullish near S1Gap 6 – Between S1 and S2 → Bearish near S1, Bullish near S2Gap 7 – Between S2 and S3 → Bearish near S2, Bullish near S3Gap 8 – Between S3 and S4 → Bearish near S3, Bullish near S4Gap 9 – Below S4 → Aggressive (no trades)Based on the gap index and price action, the strategy sets allowLong or allowShort – and displays the status on the info table.Market Status Displayed:- Bullish – near support zones; long trades allowed- Bearish – near resistance zones; short trades allowed- Waiting – new period started; zones recalculating; no trades- Aggressive – above R4 or below S4; no trades- Zone disabled – manually disabled zone; no trades# Entry Signals1. Engulfing PatternsDetects bullish and bearish engulfing with filters:- Body Only – if true, only bodies must engulf (not full range)- Min/Max Range – can be Percentage, ATR Multiplier, or Fixed- Gap Allowance – max price gap between previous close and current open - Previous or Prior Candle – at least one of the last two candles must be the opposite. color (bearish for bullish engulf; bullish for bearish engulf).This is not a random condition. The strategy only considers trades when price is near a strong structural zone (support/resistance). Because the zone itself provides the primary context for a potential reversal, the immediate previous candle does not need to be strictly opposite in color.By relaxing the requirement to "at least one of the last two," the strategy captures valid reversals at key levels that a strict, textbook rule would miss—while remaining highly selective because it only trades near strong zones.2. Pin Bar + Engulfing Combo (EMA Override)Identifies hammers/shooting stars with:- Wick/Body Ratio (Wick 3× body)Requires a clearly defined pin bar with a very small body.- Max Body/Range (Body is at most 20% of range) Ensures the body is genuinely small relative to the total range. This is the textbook definition of a pin bar/hammer. Captures true rejection candles.- Min Wick/Range (70% of range) This is the classic pin bar definition. A 70%+ wick means price aggressively rejected the level and reversed.- Sweep Lookback – bullish pinbar must break the lowest low of the previous N bars;bearish must break the highest high a pin bar that sweeps a recent extreme (lookback) and the very next candle forms an engulfing pattern in the same direction. This combo overrides the Lower TF EMA confirmation – a unique feature that captures strong momentum after a sweep.Combined Entry RequirementsAll of the following must be true:1. Valid engulfing or pin+engulf combo2. Pattern occurs near a zone (open inside zone boundaries or crossing it)3. Market status aligns with trade direction4. Daily trade limit not exceeded (default: 2)5. Relevant zone is enabled6. Price is on the correct side of EMAs (unless overridden by combo)7. HTF EMA confirms (if enabled)8. RSI not overbought/oversold (if enabled)9. Not within the no‑trade window (if enabled)-----------------------------------------------------# Confirmation FiltersCurrent TF EMA – ensures micro‑trend alignment. Overridden by pin+engulf combo.Higher TF EMA (default 150 on 1H) – filters out counter‑trend moves in the bigger picture.RSI – prevents buying above 70 and selling below 30.Bollinger Bands – blocks trades when volatility is too low (BB width below threshold).This filter is specifically designed for assets that range heavily—choppy, sideways markets.No‑Trade Window – avoids end‑of‑day volatility (active only for timeframes ≤15min).# Risk & Position Management1- Position Sizing:- Risk per trade – percentage of equity for first trade, separate for second - Position size = (Account Risk) / (Entry – SL distance).- Second trade does not increment the daily trade counter:This is a deliberate design choice. The daily trade counter tracks new trade initiations, not total positions. The second trade (pyramiding) is considered a continuation of the existing position, not a new independent decision. This ensures the strategy can scale into strong trends without consuming the daily limit, while still respecting the maximum number of new entries per session.2-Stop Loss Options:- Low-High – entry bar low/high ± buffer Tight, reactive stops. Best for scalping or when you want the SL to follow the immediate price action of the entry candle.- Swing high/low – N-bar low/high ± buffer Broader, structural stops. Ideal for swing trading or when you want the SL to respect recent market structure rather than a single bar.- Zone – zone boundary ± buffer Structural stops aligned with pivot levels. Best when you want the SL to be placed exactly at the structural support/resistance level that defines the trade.- Fixed distance – fixed price distance Simple, static stops. Useful when you know your exact risk tolerance in dollar/pip terms and want a consistent SL distance regardless of volatility.- ATR Multiplier – entry ± (ATR × multiplier) Volatility-adaptive stops. Best for Gold's changing volatility—widens during news/high volatility, tightens during calm periods.3- Take Profit:- Main R:R ratio – main R:R ratio (default 1:3), plus optional partial TP and breakeven at a lower R:R ratio.- Partial TP – close a percentage of position at a lower R:R (TP1) - Breakeven – optionally move stop to entry at TP14- Trade Counter Reset:- For TF ≤ 15m: resets at NY (9:30 AM) and London (3:30 AM) starts (configurable)This aligns with Gold's session-specific volatility and allows fresh participation in each session while preventing over-trading within a single session.- For TF > 15m: resets once per day at session start (Every new day) Session-specific behavior is less relevant on higher timeframes, and a simple daily cap is more appropriate for swing trading.5- No‑Trade Window:- Avoids high‑volatility periods (e.g., end of day)- Active only for TF ≤ 15m (16:00 PM – 18:30 PM NY time, configurable) End-of-day volatility spikes can cause excessive slippage and erratic price action on short timeframes. on TF > 15 The window is too short to be meaningful; higher timeframe traders are less affected by brief volatility spikes. 6- Session Close:- TF ≤ 15m: can close at day end and/or week end (configurable). Scalping trades on 1m–15m charts typically last minutes to a few hours. These trades are highly sensitive to Overnight gaps, Weekend gaps - 15m 10h: feature disabled. Position trading on daily+ charts lasts days to weeks. These trades aim to capture large macro moves.# Chart Display- Zone boxes – semi‑transparent red/pink with labels (R4…S4), auto‑cleanup (max 55 periods)- Trade management lines – entry (white), SL (red), TP (green), TP1/breakeven (dashed),with green/red fills; auto‑cleanup ((4) * max 125)- Info table (top‑right) : 1. shows Market Status(Bullish/Bearish/Aggressive/Waiting). 2. EMA confirmations. 3. Zone Width, Breakout threshold. 4. Engulf range max min. 5. SL settings(SL refrence, sL bufer)- EMA plots – light blue (lower TF) and light red (higher TF)- Signal shapes – hidden by default (can be enabled via style settings)- arrowdown shapes - "Reset trade counter" - Background 1 color – yellow during no‑trade window- Background 2 color – white close all position on week/day end. UI Note: Inputs are hidden from the status line to keep your chart clean. All settings (zones, EMAs, risk, patterns) remain fully adjustable in Settings → Inputs.# Default Settings – Optimized for XAUUSD (Gold)All default values have been calibrated specifically for Gold's typical volatility and intraday structure.(Setting : Default : Why This Works for Gold)----------------------------------------------------------------------------------------Period : Daily : Gold respects daily highs/lows as key structural levels.-----------------------------------------------------------------------------------------Pivot Type : Classic : Most widely used and reliable for Gold.-----------------------------------------------------------------------------------------Zone Width : ATR (0.053× ATR(14)) : ATR(14) provides a stable, week-to-week view of Gold's volatility (roughly two trading weeks of data).Adapts to Gold's daily volatility (Zone Width often $4–$10 range).-----------------------------------------------------------------------------------------Breakout Threshold : 7% of zone width : Zone width ≈ $3.00–$10.00 (Daily ATR × 0.053). 7% ≈ $0.21–$0.70 (21–70 ticks)—filters noise wicks, captures genuine breaks.Prevents false transitions caused by standard stop-hunting wicks-----------------------------------------------------------------------------------------Engulfing Range : ATR(14) (0.375× – 2.5×) : ATR(14) sits in the "sweet spot"—responsive enough to capture shifts in Gold's volatility relatively quickly, yet long enough to smooth out the daily noise and provide a reliable, consistent measure. Captures meaningful moves $3–$15—ensures candle has enough size to be meaningful, rejecting tiny $0.30–$0.50 noise patterns, while filtering out massive blow-off spikes (> $20–$25 on 15m).-----------------------------------------------------------------------------------------Pin Bar Sweep : 12 bars : 12 bars – Calibrated for Gold's 3-hour intraday cycle and session transitions. Long enough to capture genuine liquidity grabs, short enough to avoid outdated levels. -----------------------------------------------------------------------------------------Risk per trade : 2% (1st), 1% (2nd) : Balances risk with Gold's occasional false breakouts. For Gold's volatile nature, 2%-1% provides the best balance between survival and growth.-----------------------------------------------------------------------------------------Risk:Reward : 1:3 : Gold routinely moves 1.5–2× its ATR in a single directional push. A 1:3 target is well within Gold's typical daily range.-----------------------------------------------------------------------------------------Stop-Loss Reference : ATR Multiplier : For Gold's volatile nature, a static stop-loss (Fixed or Low-High) cannot adapt to changing volatility. ATR-based SL scales with market conditions—widening during high volatility (news, session opens) and tightening during calm periods. This ensures the stop-loss is always "fair" relative to current market conditions, preventing premature stops during normal volatility spikes-----------------------------------------------------------------------------------------Stop-Loss Multiplier : 1.8× ATR(14) : A 1.8× ATR(14) stop-loss represents 1.8 times Gold's average 14-period range. Why 1.8× and not 2.0× or 1.5×? Backtesting revealed that 1.8× is the "sweet spot"—wide enough to survive Gold's normal volatility spikes without being stopped out by noise, yet tight enough to limit losses -----------------------------------------------------------------------------------------Current TF EMA : 21 (Enabled, Overrideable) : On 15m chart = 5.25 hours—perfectly captures Gold's average intraday move length. Can be overridden by Pin Bar + Engulfing Combo to catch institutional reversals that occur against the short-term trend.-----------------------------------------------------------------------------------------Higher TF EMA : 150 on 1H : On Gold, a 150-period EMA on a 1H chart represents roughly 6.5 days (one full trading week) of data. By making this filter absolute, the strategy guarantees it will never take a counter-trend trade against the weekly macro-structure.trend.-----------------------------------------------------------------------------------------Filter (RSI) : length 12 : Most traders default to RSI(14), but RSI(12) is intentionally faster for Gold's volatile intraday moves. Gold often spikes into overbought/oversold territory and reverses quickly. A 12-period RSI reacts ~15% faster than RSI(14), catching these reversals earlier while remaining smooth enough to avoid excessive whipsaws.----------------------------------------------------------------------------------------- Filter (Bollinger Bands) : Disabled by default : Gold is historically a trending asset with strong directional moves. A low-volatility filter would unnecessarily block valid entries during these trends. Designed for range-bound assets (choppy crypto, certain forex crosses)—enable it only if your market consolidates heavily.-----------------------------------------------------------------------------------------These values are a starting point – you may adjust them for other assets or personal risk tolerance.# Important Notes on Backtest Realism - Commission – Most ECN/raw-spread brokers charge $3.00–$3.50 per side (round-turn commission of $6.00- $7.00) for 1 standard lot (100 oz) of XAUUSD. Standard accounts usually build the fee into a wider spread instead of charging a separate cash. This strategy deducts $3.50 per entry and $3.50 per exit ($0.035 × 100 oz)round-turn commission of $7.00. Adjust this to match your broker's exact fees.- 4 ticks Slippage - For XAUUSD, 1 tick = $0.01 per ounce. 4 ticks = **$0.04 per ounce (unit)**. Accounts for real-world price . Prevents overly optimistic backtest equity curves.Always adjust the commission value to your broker's exact fee structure before relying on the results."A backtest without realistic commission and slippage is a fantasy. A backtest with realistic commission and slippage is a truthful reflection of what you can expect when trading live."- Intra-Bar Execution: The strategy uses calc_on_every_tick = true, meaning it recalculates on every price tick during real-time trading. This allows the breakeven and partial TP logic to trigger immediately when price hits TP1, protecting the trade from intra-bar reversals.Note: Backtests use OHLC data only, so intra-bar fills and breakeven triggers cannot be perfectly simulated. Real-time performance may differ from backtest results due to this limitation # The Core Innovation (Why This Isn't Just a Mashup)This strategy is built on a three-layer validation system. Each layer solves a specific problem that the other layers cannot solve alone.Layer 1 (The Structure): Dynamic Pivot ZonesLayer 2 (The Trigger): Pin-Bar Sweep + Engulfing ComboLayer 3 (The Execution): Gap State MachineHere is how they interdepend to create a unique edge:1. Adaptive Pivot Mathematics (The "Regime Matching" Logic)Instead of offering multiple pivot types just for the sake of it, this strategy provides them so the trader can match the mathematical formula to the market's current behavioral regime:Why this matters: Most strategies lock you into one formula. This strategy acknowledges that price dynamics change, and it gives you the mathematical weapon to adapt without rewriting the entire code.2. The "Liquidity Grab" Trigger (Sweep + Engulfing Combo)This is the most critical edge of the strategy. A standard Engulfing pattern is common. A standard Pin Bar is common. But when they occur sequentially—a Pin Bar that sweeps the 12-bar extreme, immediately followed by an Engulfing candle—it represents a textbook institutional "liquidity grab."- The Logic: Large players often push price to sweep obvious stop-losses (above highs or below lows) before reversing the trend.- The Override: Crucially, this specific combo overrides the Lower TF EMA confirmation.- Why this is a breakthrough: Standard trend-following strategies with a hard EMA filter will miss these reversals because price is moving against the EMA in the short term. By programming this specific override, the strategy captures the exact moment of institutional reversal—catching the move before the EMA flips and the trend-followers finally enter.3. The Gap State Machine (Dynamic Sentiment Tracking)Unlike static support/resistance scripts that just plot lines and wait for touches, this strategy features a state machine that tracks which of the 9 gaps (between R4-R1, Pivot, S1-S4) the price currently occupies.- The Mechanism: A Breakout Threshold (default 7% of zone width) acts as a "dead-zone" filter. Price must exceed this threshold to officially transition from one gap to another.- The Alpha: This prevents the strategy from whipsawing during minor noise. When price crosses from Gap 4 (between R1 and Pivot) into Gap 3 (between R2 and R1), the strategy instantly and autonomously switches market status from "Bearish" to "Bullish" or vice versa. 4. Selective Zone Activation (Strategic Discretion) - This strategy allows the user to completely disable specific zones (e.g., turn off R3).- The Value: By disabling a weak level, the user forces the strategy to wait for the next stronger level, instantly increasing the win rate and filtering out historically weak signals without altering any other code.5. Non-Invasive Risk Architecture (Clean Defaults)For traders who want to reduce psychological pressure or optimize for Gold's notorious retracements, they can enable these modules. When activated, the strategy closes % of the position at a lower R:R threshold and moves the remaining position to breakeven—locking in profits while letting the rest run.In Summary: The "Mashup" JustificationThis is not a random collection of indicators.1. The State Machine provides the structural context.2. The Pin+Engulf combo provides the high-conviction trigger that overrides slow-moving filters.3. The Selectable Pivot Types provide the mathematical adaptability to different assets.4. The Selectable Zones provide the manual discretion to avoid historical losing levels.5. The Disabled TP/BE by default provides a clean baseline for evaluating the core logic.Author: Awab_Hassan