H Bandys PIRDPO
- Experts
- MATTHEW STAN WILLS
- Versione: 1.0
- Attivazioni: 10
Howard Bandy's - PIRDPO (Position in Range Detrended Price Oscillator)
A professional implementation of Howard Bandy's PIRDPO (Position In Range of Detrended Price Oscillator) strategy, designed to systematically capture high-probability short-term reversals in equity markets.
PIRDPO measures where the current detrended price sits relative to its recent history, expressed as a percentile from 0 to 1. When the percentile is low, price is at the bottom of its detrended range — a classic mean reversion setup that this EA captures with disciplined, rule-based execution.
Core Edge
The Detrended Price Oscillator removes long-term trend effects to isolate short-term cycles. PIRDPO takes this further by ranking the current DPO reading against its recent history as a percentile:
- A low percentile (near 0) means price is at an extreme low relative to its detrended range
- A high percentile (near 100) indicates an overbought condition for short trades
- The range is recalculated on every bar, automatically adjusting to current volatility
- No fixed thresholds to re-optimize -- PIRDPO is self-calibrating
Unlike fixed-threshold indicators, PIRDPO adapts to recent market conditions by ranking the current reading as a percentile — making it self-calibrating across different volatility regimes.
How PIRDPO Is Calculated
PIRDPO is built in two steps. First, the Detrended Price Oscillator (DPO) removes the trend by measuring the percentage distance between the closing price and its simple moving average:
DPO = (Close - SMA) / SMA
The SMA period is configurable (default 20). When the close is below the moving average, DPO is negative. When above, DPO is positive. Dividing by SMA normalizes the result as a percentage, so the value is comparable across different price levels.
Second, the current DPO is ranked as a percentile within its recent range. The EA finds the minimum and maximum DPO values over a lookback window (default 20 bars) and calculates:
PIRDPO = 100 x (DPO_current - DPO_min) / (DPO_max - DPO_min)
This produces a value between 0 and 100. A reading of 0 means the current DPO is at the lowest point of its recent range — maximum oversold. A reading of 100 means it is at the highest point — maximum overbought. Because the range is recalculated on every bar, PIRDPO automatically adjusts to current volatility conditions without requiring fixed thresholds.
Research Foundation
Based on Howard Bandy's PIRDPO indicator from "Mean Reversion Trading Systems" (Blue Owl Press, 2013). PIRDPO uses two components: a DPO Moving Average Period (default 20) that detrends price, and a PIRDPO Lookback Period (default 20) that ranks the current reading as a percentile.
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: PIRDPO drops below 15 (default) while price is above the SMA trend filter
- Exit: PIRDPO rises above 80 (default), or Take-Profit target is hit (default 1.0%), or N-bar timeout expires (default 10 bars) -- whichever comes first
Short side (disabled by default):
- Entry: PIRDPO rises above 85 (default) while price is below the SMA trend filter
- Exit: PIRDPO drops below 20 (default), or Take-Profit target is hit, or N-bar timeout expires -- whichever comes first
Two entry modes are available:
- Standard: single entry per signal
- Aggressive: adds one additional position on the next bar if the signal remains active
Typical System Behaviour
- High win rate (often 65 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
- Triple-exit framework: PIRDPO-based exit, profit target, and time-based exit
- Standard and Aggressive entry modes
- 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 entry and exit markers, PIRDPO indicator values, 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
DPO Moving Average Period (default: 20) - The period for the simple moving average used in the DPO calculation. DPO = (Close - SMA) / SMA. A longer period smooths out more trend, isolating longer cycles.
PIRDPO Lookback Period (default: 20) - The number of bars used to calculate the min/max DPO range for the percentile ranking. PIRDPO = (DPO_current - DPO_min) / (DPO_max - DPO_min). A longer lookback creates wider percentile ranges and fewer signals.
Long System
Enable Long (default: true) - Toggles long (buy) trading on or off.
Entry Mode (default: Standard) - Standard = single entry per signal. Aggressive = adds one additional position on the next bar if the signal remains active.
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: PIRDPO Below (default: 0.15) - When PIRDPO drops below this percentile level, a long entry is triggered. Values near 0 indicate extreme oversold conditions.
Exit: PIRDPO Above (default: 0.80) - When PIRDPO rises above this percentile, all long positions are closed.
Exit: Take Profit % (default: 1.0) - Percentage profit target submitted at broker level. Set to 0 to disable.
Exit: N-Bar Timeout (default: 10) - Close position after N bars if no other exit triggered. Set to 0 to disable.
Aggressive: 2nd Entry Multiplier (default: 1.0) - Position size multiplier for the second entry in Aggressive mode.
Short System
Enable Short (default: false) - Toggles short (sell) trading on or off. Disabled by default.
Entry Mode (default: Standard) - Standard = single entry per signal. Aggressive = adds one additional position on the next bar if the signal remains active.
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: PIRDPO Above (default: 0.85) - When PIRDPO rises above this percentile level, a short entry is triggered.
Exit: PIRDPO Below (default: 0.20) - When PIRDPO drops below this percentile, all short positions are closed.
Exit: Take Profit % (default: 1.0) - Percentage profit target for short positions. Set to 0 to disable.
Exit: N-Bar Timeout (default: 10) - Maximum bars to hold a short position before closing at market. Set to 0 to disable.
Aggressive: 2nd Entry Multiplier (default: 1.0) - Position size multiplier for the second entry in Aggressive mode.
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 PIRDPO percentile rankings. However, percentile rankings can stay at extremes 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.
