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

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明