H Bandys zScore
- Эксперты
- MATTHEW STAN WILLS
- Версия: 1.0
- Активации: 10
Howard Bandy's - Naive Mean Reversion System - version 1.0
A professional implementation of Howard Bandy's Z-Score strategy, designed to systematically capture high-probability short-term reversals in Indicies, ETFs and Equity markets.
The Z-Score measures how many standard deviations the current price is from its recent mean. When price deviates significantly below the mean (negative Z-Score), statistical probability favours a reversion back toward average. This is one of the most mathematically rigorous approaches to mean reversion trading.
Core Edge
The Z-Score is a pure statistical measure of how far price has deviated from its recent average:
- A Z-Score of -1.0 means price is one standard deviation below the mean
- Well-understood probability distributions underpin the signal
- No subjective interpretation required -- purely mathematical
- Consistent across different price levels and instruments
Unlike subjective oversold readings, the Z-Score provides an objective, mathematically grounded way to identify when mean reversion is likely — making it one of the most rigorous approaches to short-term trading.
How Z-Score Is Calculated
The Z-Score standardizes how far price has deviated from its recent average, measured in units of standard deviation. It uses a single lookback period (default 10 bars) for both the mean and the volatility estimate:
SMA = Simple Moving Average of Close over N bars StdDev = Standard Deviation of Close over N bars
Z-Score = (Close - SMA) / StdDev
When the close is below the moving average, the numerator (Close - SMA) is negative, producing a negative Z-Score. Dividing by standard deviation normalizes the result so that a Z-Score of -1.0 always means "one standard deviation below the mean," regardless of the instrument's price level or typical volatility.
In a normal distribution, roughly 68 percent of observations fall within one standard deviation of the mean. A Z-Score of -1.0 places price in the lower tail — a statistically significant oversold condition. The default entry threshold of -1.0 captures these events, while the exit at -0.25 closes the trade as price begins reverting toward the mean (note this is still negative — the system exits early rather than waiting for a full reversion to zero).
Research Foundation
Based on Howard Bandy's Z-Score application from "Mean Reversion Trading Systems" (Blue Owl Press, 2013). The Z-Score is calculated as (Close - SMA) / StdDev over a lookback period, producing a normalized measure that works consistently across different price levels and instruments.
Bandy's mean reversion strategies were originally designed as long-only systems, reflecting the natural upward bias of equity markets. The short side has been coded into this EA for those who wish to experiment, but the long side is where the primary research edge lies.
Strategy Rules
Long side:
- Entry: Z-Score drops below -1.0 (default) while price is above the SMA trend filter
- Exit: Z-Score rises above -0.25 (default). Note this is still negative -- the system exits once price begins reverting toward the mean, not waiting for a full reversion. Take profit and N-bar timeout are available but OFF by default
Short side (disabled by default):
- Entry: Z-Score rises above 1.0 (default) while price is below the SMA trend filter
- Exit: Z-Score drops below 0.25 (default). Take profit and N-bar timeout are available but OFF by default
Optional scaling allows additional entries on subsequent bars if the Z-Score remains at extreme levels.
Typical System Behaviour
- High win rate (often 70 to 85 percent depending on market and settings)
- Small, consistent gains per trade
- Occasional drawdowns during strong trending markets
- Performs best on liquid equity indices and ETFs
This is a mean reversion system, not a trend-following strategy. It profits from short-term pullbacks rather than large directional moves.
Who This EA Is For
Ideal for:
- Traders building multi-strategy portfolios
- Users familiar with systematic trading concepts
- Traders targeting consistency over aggressive returns
Not suitable for:
- "Set and forget" users expecting constant profits
- Traders who cannot tolerate temporary drawdowns
- Users seeking high-risk, high-return systems
Key Features
- Fully automated execution on MetaTrader 5
- Multi-symbol trading: up to 10 markets from a single chart
- Three position sizing modes: Fixed Lots, Dollar Value, and Account Percentage
- Automatic currency conversion for cross-currency instruments
- Z-Score level exit provides statistically grounded signal management
- Optional scaling into deeper pullbacks
- Optional enhanced exits: Take Profit (%) and N-Bar Timeout
- Built-in performance dashboard with win rate, P&L, average trade, and open positions
- Alerts via chart popups, push notifications, and email
Recommended Markets
Best suited for:
- US equity indices: S&P 500 (US500), NASDAQ 100 (NDX100/US100), Dow Jones (US30)
- Other liquid indices: Russell 2000 (US2000), ASX 200, DAX 40, FTSE 100
- Equity ETFs: SPY, QQQ, DIA, IWM, XLK
Individual equities can be traded but carry higher risk. Single stocks are inherently more volatile than indices and ETFs, and their downside risk during company-specific events is substantially larger. If trading individual equities, use conservative position sizing and always backtest first.
Not recommended for Forex or commodities unless specifically tested. Do not mix asset classes in the same EA instance.
Screenshots
Screenshots show individual trade examples on SPY with Z-Score indicator values, entry and exit markers, and strategy details.
Part of a Professional EA Series
This EA is one of 9 mean reversion strategies available from M.Wills. All target the same core edge — short-term pullbacks in trending markets — but each uses a different signal to identify when that pullback has gone far enough. Running multiple uncorrelated entry signals together can reduce drawdowns, improve consistency, and smooth equity curves.
The series includes:
- Connors TPS (scale-in with RSI)
- Connors RSI2 (RSI extreme readings)
- Connors Double 7s (7-day price channel)
- Connors Percent B (Bollinger Band %b)
- Bandy Naive MR (consecutive down days)
- Bandy PIRDPO (detrended price oscillator)
- Bandy RVI2 (relative vigor index)
- Bandy DV2 (close-to-midpoint momentum)
- Bandy Z-Score (statistical z-score)
Expert Advisor Settings
General Settings
Magic Number (default: 12345) - Unique identifier for this EA's trades. Use different numbers when running multiple EAs on the same account to prevent trade conflicts.
Trade Entry Mode (default: Open of Next Bar) - Controls when trades are executed:
- OPEN OF NEXT BAR: Places trades at the next bar open. Best for backtesting.
- CLOSE OF THIS BAR: Executes near the daily session close. Recommended for live trading.
- EXACT TIME: Executes at a user-defined time each day using the broker's server clock.
Exact Time (default: 23:54) - The time in HH:MM format used when Trade Entry Mode is set to Exact Time.
Timeframe (default: Current) - The chart timeframe for analysis. Daily is recommended.
Position Sizing
Sizing Mode (default: Lot Size) - Determines how position size is calculated:
- LOT SIZE: Uses a fixed number of lots per trade entry.
- TRADE VALUE $: Allocates a fixed dollar amount per trade, automatically converted to the correct lot size.
- ACCOUNT BALANCE %: Allocates a percentage of the current account balance per trade.
Position Size (default: 0.01) - The value applied to the selected sizing mode.
Max Margin % of Equity (default: 30.0) - Safety limit that caps how much margin a single trade can consume relative to account equity. Before every trade, the EA calculates the required margin and checks whether it would exceed this percentage of current equity. If it would, the trade is skipped and a message is logged to the Journal. This prevents accidental over-leverage on brokers with high minimum lot sizes. Set to 0 to disable.
Symbol Management
Additional Symbols (default: blank) - Comma-separated list of additional symbols to trade from a single chart (e.g. US500,NDX100,ASX200). Leave blank to trade only the chart symbol.
Max Symbols Open at Once (default: 2) - Maximum number of symbols that can have active trades simultaneously.
Indicator Settings
Z-Score Lookback Period (default: 10) - The number of bars used to calculate the mean (SMA) and standard deviation for the Z-Score. A larger period produces a more stable, longer-term measure; a smaller period is more responsive to recent moves.
Long System
Enable Long (default: true) - Toggles long (buy) trading on or off.
Trend Filter: Price > SMA (default: true) - Long trades are only taken when price is above the moving average, ensuring trades align with the broader uptrend.
Trend Filter: SMA Period (default: 200) - The lookback period for the trend filter.
Entry: Z-Score Below (default: -1.0) - When Z-Score drops below this level, a long entry is triggered. A value of -1.0 means price is one standard deviation below the recent mean.
Entry: Additional on Subsequent Days (default: 0) - If the Z-Score remains at extreme levels after the initial entry, take additional positions. Set to 0 for a single entry only.
Exit: Z-Score Above (default: -0.25) - When Z-Score rises above this level, long positions are closed. Note this is still negative — the system exits once price begins reverting toward the mean, not waiting for a full reversion.
Exit: Take Profit % (default: 0.0) - Percentage-based profit target. Disabled by default — the Z-Score level exit is the primary exit mechanism. Set to a percentage value to enable.
Exit: N-Bar Timeout (default: 0) - Maximum bars to hold a position. Disabled by default. Set to a non-zero value to add a time-based exit.
Short System
Enable Short (default: false) - Toggles short (sell) trading on or off. Disabled by default.
Trend Filter: Price < SMA (default: true) - Short trades are only taken when price is below the moving average, ensuring trades align with the broader downtrend.
Trend Filter: SMA Period (default: 200) - The lookback period for the trend filter.
Entry: Z-Score Above (default: 1.0) - When Z-Score rises above this level, a short entry is triggered. A value of 1.0 means price is one standard deviation above the recent mean.
Entry: Additional on Subsequent Days (default: 0) - If the Z-Score remains at extreme levels after the initial entry, take additional positions. Set to 0 for a single entry only.
Exit: Z-Score Below (default: 0.25) - When Z-Score drops below this level, short positions are closed. The system exits once price begins reverting toward the mean.
Exit: Take Profit % (default: 0.0) - Percentage-based profit target for short positions. Disabled by default.
Exit: N-Bar Timeout (default: 0) - Maximum bars to hold a short position before closing at market. Disabled by default.
Display Settings
Show Dashboard (default: true) - Displays the on-chart information panel showing all active settings and current trade status.
Font Size (default: 20) - Text size for the dashboard display.
Show Trade Metrics (default: true) - Includes performance statistics in the dashboard: total trades, win/loss ratio, accuracy, average trade, and cumulative P&L.
Metrics Start Date (default: 2000.01.01) - Starting date for performance calculations.
Alerts and Notifications
Chart Alerts (default: false) - Enable on-chart popup alerts when trade signals are generated.
Push Notifications (default: false) - Enable mobile push notifications for trade signals. Requires push notifications to be configured in the MetaTrader 5 terminal.
Email Notifications (default: false) - Enable email notifications for trade signals. Requires email to be configured in the MetaTrader 5 terminal settings.
Backtesting and Execution Notes
This strategy is designed for entry at the close of the trading day, when the signal is first identified. Backtesting research shows that entering at the close provides a measurable edge over waiting for the next day's open.
- Default mode: Open of Next Bar (required for MQL5 Market validation)
- Recommended for live trading: Close of This Bar, or Exact Time (1-2 minutes before market close)
- Set Exact Time to match your broker's daily close (e.g. 23:54 for a server that closes at 23:55)
Backtesting tips:
- Use "1 minute OHLC" or higher tick model for accurate results on daily bars
- Do not use "Open prices only" for daily timeframe strategies
- Close of This Bar and Exact Time modes may not function correctly in the Strategy Tester
Additional notes:
- Do not mix different asset classes in the same EA instance
- For Forex and Metals, use the Lot Size position sizing method only -- Trade Value and Account Percentage modes are designed for stocks and indices
Requirements
- MetaTrader 5 platform (Hedging or Netting account)
- Minimum recommended leverage: 1:30
- Daily timeframe preferred
- All symbols must be available in your broker's Market Watch
Support
If you need custom adjustments or have questions, leave a comment with your email and we will get back to you. Always test the EA on a demo account before running it on a live account.
Risk Disclosure
This EA trades mean reversion setups using statistical Z-Score readings. However, Z-Scores can remain at extreme levels during sustained trends, and exits may not prevent losses during severe drawdowns. Backtests use historical data and do not account for slippage, partial fills, or changing market conditions. Proper position sizing relative to account equity is essential. Always test with demo accounts before trading live. Past performance does not guarantee future results.
