DMI Balance Buy Sell Strategy
This strategy generates buy and sell signals based on the Direction Movement Index (DMI) indicators for trend direction. It utilizes the crossover of DMI's two indicators, DMI+ and DMI-, as well as their crossover…

Overview
This strategy generates buy and sell signals based on the Direction Movement Index (DMI) indicators for trend direction. It utilizes the crossover of DMI's two indicators, DMI+ and DMI-, as well as their crossover with ADX to determine the bullish/bearish state and trend of the market, thereby producing entry and exit signals.
Strategy Logic
The strategy mainly uses three indicators from DMI: DMI+, DMI- and ADX. DMI+ reflects the strength of an uptrend, DMI- reflects the strength of a downtrend, while ADX reflects the trend intensity.
The buy signal is triggered when DMI+ crosses over DMI- and also crosses over ADX, indicating a switch from a bearish to bullish state and an emerging trend.
The sell signal is triggered when DMI+ crosses below either DMI- or ADX, indicating weakening bullish momentum and a need to take profit.
Therefore, the strategy dynamically adjusts positions by judging market sentiment and trend changes using the crossover patterns of the DMI indicators.
Advantage Analysis
The main advantages of this strategy are:
Using DMI for trend and sentiment analysis provides reliability in capturing major trends.
Incorporating ADX to gauge trend strength allows more accurate identification of inflection points.
The simple, clear crossover signals of DMI indicators make this strategy easy to implement.
Running with the trend provides good risk control, suitable for medium- to long-term holding periods.
Risk Analysis
Several risks to note:
DMI indicators have some lag, which may result in late buys and premature sells.
ADX has mediocre performance in distinguishing between trends and consolidations, thus some short-term opportunities may be missed.
There is some risk of holding no positions, in case persistent uptrend or downtrend occurs.
Parameter optimization risks exist, which may lead to deteriorated performance in live trading.
Improvement Areas
Some ways to improve this strategy:
Incorporate other indicators to spot momentum divergence, enhancing accuracy of entries and exits.
Add stop-loss mechanisms to limit loss in adverse moves.
Adjust parameters or introduce adaptive settings to mitigate optimization bias.
Implement position sizing to dynamically adjust stakes according to trend stages.
Conclusion
This DMI trend-following strategy is simple and practical for catching major trends over medium- to long-term horizons. However, lags, empty positions, and parameter optimization risks exist. Enhancements through combining indicators, stop losses, adaptive parameters etc. can improve live performance.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 14 | DMI Length |
Source Pine Script
//@version=5
strategy("DMI Buy/Sell Strategy", overlay=true)
// Input for DMI
length = input(14, title="DMI Length")
adxsmoothing =14
// Calculate DMI
[diPlus, diMinus, adx] = ta.dmi(length,adxsmoothing)
// Condition for Buy Entry
buyCondition = ta.crossover(diPlus, diMinus) and ta.crossover(diPlus, adx)
// Condition for Sell Exit
sellCondition = ta.crossunder(diPlus,diMinus) or ta.crossunder(diPlus,adx)
// Execute Buy Entry on the next day's open
if buyCondition
strategy.entry("Buy", strategy.long)
// Execute Sell Exit on the next day's open
if sellCondition
strategy.close("Buy")
// Plotting DMI components
plot(diPlus, title="DMI+", color=color.green)
plot(diMinus, title="DMI-", color=color.red)
// Plotting ADX
plot(adx, title="ADX", color=color.blue)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-02. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/DMI-Balance-Buy-Sell-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- ADX Momentum Trend StrategyPine Script · Momentum · 10m
- Advanced Multi Indicator Trend Following and Momentum Quantitative Trading StrategyPine Script · Momentum · 1h
- Dual EMA Crossover with RSI Momentum Enhanced Trading StrategyPine Script · Momentum · 1d
- Dual EMA Momentum Trend Trading Strategy with Full Body Candle Signal SystemPine Script · Momentum · 2h
- Ergotic Momentum Direction Convergence Trading StrategyPine Script · Momentum · 1d
- Laguerre RSI with ADX Filtered Trading Signals StrategyPine Script · Momentum · 1d