VWAP SD2 Reversion (Long) — Strategy by jswapnil
By jswapnil
Performance Metrics
- Author: jswapnil
- Symbol: PEPPERSTONE:AUDUSD
- Timeframe: 5 minutes
- Win Rate: 37.0%
- Profit Factor: 1.661
Description
A patient, momentum-confirmed dip buyer that fades stretches below the session VWAP and targets a return to the mean.The ideaIntraday price tends to oscillate around its volume-weighted average price (VWAP). When price extends a full two standard deviations below the session VWAP, it is statistically stretched and often springs back toward the average. This strategy is built to capture that snap-back, but it deliberately does not buy the dip blindly. A stretched market can keep falling, so the strategy waits for two independent momentum tools to confirm that the down-move has actually turned before it commits.The result is a sequential, time-boxed setup: a volatility filter, a price stretch, and then two momentum confirmations that must all line up within a short window. If they do not, the setup is discarded and the strategy stays flat.How a trade is builtEach long requires the following to occur in order, with every step happening at or after the initial dip and within the confirmation window:Volatility filter: the lower 2-SD band must sit at least a minimum distance from VWAP (default 10 pips). This skips quiet, low-range conditions where there is little room to revert and the costs would dominate.Step 1, the stretch: price closes below the lower 2-SD band.Step 2, RSI confirms: RSI recovers back above its level (default 30), confirming the oversold push is fading.Step 3, MACD confirms: the MACD line turns bullish over its signal line (or over zero, if you prefer), confirming momentum has flipped up.Entry: a market long is taken on the bar that completes Step 3.Why a state machineReal momentum turns are messy. RSI and MACD often flip within a bar or two of each other, and sometimes on the very same bar. A naive rule that demands three separate single-bar crossovers in strict order misses most of these clusters. This strategy instead tracks the setup through a small state machine that:anchors both confirmations to the first dip bar, so a momentum cross that happened before the dip cannot be borrowed to validate the trade;accepts confirmations that arrive in either order or on the same bar, as long as both are recent and post-dip;keeps the setup alive while price continues to hug the band, and expires it cleanly once the confirmation window passes without a trigger.A Strict toggle is provided for those who want the original behaviour, where each step must be a fresh crossover on a later bar.How the exit worksBecause the thesis is reversion to the mean, the natural profit target is the mean itself. By default the take-profit is the live VWAP, re-evaluated every bar so it tracks the line as it moves, set a small buffer in front so the order fills on the approach rather than waiting for an exact touch. A minimum-profit floor prevents a falling VWAP from dragging the target back through the entry.A fixed-pip take-profit mode is available as an alternative. The stop-loss is a fixed pip distance below entry in both modes. Targeting the mean rather than a fixed number of pips tends to produce variable, often larger winners, which also dilutes the impact of fixed spread costs.SettingsSetupSD band multiplier — standard-deviation width of the bands (default 2.0).Min VWAP to SD2 distance — the volatility filter, in pips (default 10).Confirmation window — how many bars each step has to confirm (default 5).Strict cross — require a fresh crossover on a bar after the prior step.RSI and MACDStandard RSI length and cross level.Standard MACD fast, slow and signal lengths, with an optional zero-line cross instead of a signal-line cross.Risk and pipsTP at VWAP, with a front-run buffer and a minimum-profit floor, or a fixed-pip take-profit.Stop loss in pips.Auto pip size (mintick × 10), which resolves correctly for 5-decimal FX and 3-decimal JPY pairs, plus a manual override.Reading the chartOrange line: session VWAP (the reversion target).Red and green lines: the lower and upper 2-SD bands.Markers: 1 marks a close below the band, 2 marks the RSI confirmation, and the triangle marks the MACD confirmation and entry trigger.Intended useThis is an intraday strategy, developed and tuned on 5-minute FX majors, with a daily VWAP anchor that resets each session. In the author's testing it has behaved most consistently on AUDUSD, and it is also designed for pairs such as EURUSD and USDJPY. As always, behaviour varies by pair, broker feed and period, so test it on your own data before relying on it.On backtest settings: tight intraday targets are sensitive to execution costs. Before drawing conclusions from the Strategy Tester, set a commission and slippage that match your broker, and choose a position size that reflects the risk you would actually take. Results shown with unrealistic costs can look far better than anything achievable live.This script is published for educational and research purposes only and is not financial advice or a recommendation to trade. Backtested and hypothetical results do not guarantee future performance, and trading leveraged instruments such as FX carries substantial risk of loss. You are responsible for your own testing, risk management and decisions.Release NotesThe "missing entries" saga: not a logic bug — it was the backtest margin/order-size not matching your broker. Now baked in: 1 lot, $10k, 500:1.Diagnostics on the chart: 1/2/▲ steps, ✕ blocked-by-position, R order-rejected. The R is the tripwire — if it ever reappears, it's a sizing/margin issue, not the signal.