DMI Modified Zero-Cross + MA Confluence Strategy by cryptosquanch
By cryptosquanch
Performance Metrics
- Author: cryptosquanch
- Symbol: OANDA:USDJPY
- Timeframe: 1 hour
Description
DMI Modified Zero-Cross + MA Confluence Strategy is an open-source strategy that trades confirmed zero-line crosses of a smoothed DMI oscillator. It adds optional strength, trend and time filters, and several stop, target and exit models. It is published as a research and testing framework. The default backtest on the chart loses money after costs, and that result is reported below.CREDITThe oscillator follows the "DMI Modified" indicator concept by dman103: +DI minus -DI, smoothed with a selectable moving average, including a Jurik-style (JMA) option. Credit to the original author for the idea and the open-source code it builds on. This script turns that oscillator into a complete strategy. It adds entry confirmation, filters, risk management, trade management and on-chart trade review, none of which are part of the original indicator. For the oscillator in its own pane, add dman103's "DMI Modified" indicator to the chart separately.HOW IT WORKSThe oscillator+DI and -DI are calculated from directional movement and Wilder-smoothed true range over the DMI length (default 7). Their difference (+DI - -DI) is positive when upward movement dominates and negative when downward movement dominates. It is then smoothed (default JMA, length 3) to reduce noise.Entries- Long: the smoothed DMI makes a fresh, confirmed bar-close cross from below 0 to above 0.- Short: a fresh, confirmed cross from above 0 to below 0.- Optional hold bars: the oscillator must stay on the new side for X more closed bars before the entry is allowed.- Optional filters, each OFF by default and switchable on its own: minimum |DMI| after confirmation, minimum ADX (trend strength from the standard ADX), and an MA stack filter (up to 5 MAs that must be in bullish or bearish order).- Optional time blocks stop new entries during set windows, and can also close open trades.- One position at a time, no pyramiding, bar-close logic only.Why these parts are combinedA zero-line cross by itself fires often in sideways markets. Each filter targets a specific type of false signal: hold bars target crosses that immediately reverse, the magnitude and ADX filters target weak or trendless moves, and the MA stack targets trades against the higher trend. They are separate switches so you can measure what each one adds or costs in the Strategy Tester.Exits- Stop-loss modes: signal-bar offset (default: 3 pips beyond the signal bar's low for longs or high for shorts), fixed pips, percent, or ATR.- Take-profit modes: risk:reward (default 2.0), fixed pips, percent, ATR, or signal-bar range extension.- Optional trailing stop that activates only after the base target is touched, with a choice of TP-level or breakeven floor.- Optional early exits: on the opposite zero-line cross, when the DMI weakens, or when the DMI reaches a chosen magnitude.DEFAULT SETTINGS AND STRATEGY PROPERTIES (used for the published chart)- Chart: OANDA:USDJPY, 1 hour. Strategy Tester range Jan 2023 to Nov 2026.- DMI length 7, JMA smoothing 3, hold bars 0. Magnitude, ADX and MA filters OFF.- Stop: signal-bar offset 3 pips. Target: 2R. Trailing and early exits OFF. Re-entry cooldown 1 bar.- Time blocks ON, New York time: 16:45-18:15 (daily rollover, when spreads usually widen) and 08:15-09:30 (scheduled US data releases). New entries only.- Initial capital: 10,000 USD. Order size: 10,000 USD of notional per trade (0.10 lot on USDJPY), converted to units at the entry price. Margin 5% (20:1).- Commission 0.005% per side. Slippage 5 ticks per fill (0.5 pip). Together these roughly represent a typical retail spread of about 1 pip round trip.- Risk per trade: the stop sits just beyond the signal bar. In the test period the average losing trade was about 0.17% of equity, and the largest single loss was about 170 USD (roughly 1.7% of starting equity).WHAT THE BACKTEST SHOWSWith these defaults the strategy made about 870 trades over the test period and lost money after costs: about -22% net, a maximum drawdown of about 27%, and a profit factor below 1 (about 0.8). Trading costs account for a large share of that loss because the unfiltered zero-cross trades often. I am publishing the honest default result instead of tuning settings to make the past look good. The script is meant for testing which filters, timeframes and exit models change the outcome, not as a ready-made system. Past results do not predict future performance.HOW TO USE IT1. Set Strategy Properties (capital, commission, slippage) to match your broker.2. Set the pip size for your instrument (0.01 for JPY pairs, 0.0001 for most other FX pairs).3. Turn the filters on one at a time (hold bars, ADX, magnitude, MA stack) and compare the Strategy Tester results with the defaults.4. Use the trade boxes, labels and status panel to see why each trade was taken and how it exited.This script is for research and education. It is not financial advice.