OPEN-SOURCE SCRIPT

DMI Strategy

█ STRATEGY DESCRIPTION
The "DMI Strategy" is a trend-following strategy that uses the Directional Movement Index (DMI) and a 200-period Exponential Moving Average (EMA) to identify potential long entries. It enters a long position when specific conditions are met and exits when the Relative Strength Index (RSI) indicates overbought conditions. This strategy is designed for use on daily or higher timeframes.

█ WHAT IS THE DMI?
The Directional Movement Index (DMI) consists of three components:
- **DI+ (Plus Directional Indicator)**: Measures upward trend strength.
- **DI- (Minus Directional Indicator)**: Measures downward trend strength.
- **ADX (Average Directional Index)**: Measures overall trend strength, regardless of direction.

In this strategy, only the DI+ and DI- components are used to identify potential entry signals.

█ SIGNAL GENERATION
1. LONG ENTRY
A Buy Signal is triggered when:
  • The DI+ value is less than 5, indicating weak upward momentum.
  • The close price is above the 200-period EMA, confirming a bullish trend.
  • The signal occurs within the specified time window (between `Start Time` and `End Time`).


2. EXIT CONDITION
  • A Sell Signal is generated when the 2-period RSI exceeds 65, indicating overbought conditions. This prompts the strategy to exit the position.


█ ADDITIONAL SETTINGS
  • DI Length: The lookback period for calculating the DMI components. Default is 3.
  • Start Time and End Time: The time window during which the strategy is allowed to execute trades.


█ PERFORMANCE OVERVIEW
  • This strategy is designed for trending markets and performs best when the price is above the 200-period EMA.
  • It is sensitive to overbought conditions, as indicated by the RSI, which helps to lock in profits.
  • Backtesting results should be analysed to optimize the DI Length and RSI parameters for specific instruments.
Breadth IndicatorsChart patternsCyclesdaytradingDMIIndicesmeanreversionQQQSPDR S&P 500 ETF (SPY) Stocksswingtrading

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal