Pine Script v5 · Strategy
DMI Strategy
A Pine Script v5 strategy built on Change (high) and RMA (ta.tr, 11). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 2 settings; defaults include ADX Smoothing 11 and DI Length 11.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does DMI Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
- How did DMI Strategy do on BTCUSDT 1D with default settings?
- +8.53%
- From 26 Jan 2024 to 21 Oct 2026, over 6 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does DMI Strategy run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 6 before, 10 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does DMI Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does DMI Strategy run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 22 ms, in the browser.
BTCUSDT · 1D · default settings
- +DI
- -DI
- HLine
- HLine
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +8.53%
- $85,254.30
- Buy and hold
- +102.5%
- same period
- Closed trades
- 6
- 3 won · 3 lost
- Profitable
- 50.0%
- of closed trades
- Profit factor
- 5.98
- gross profit ÷ gross loss
- Max drawdown
- 2.66%
- −$26,644.20
One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A short position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| ADX Smoothing | 11 | int · min 1 · max 50 | adx |
| DI Length | 11 | int · min 1 | trur plus minus |
What it calculates
- Changehigh
up · line 9 - Changelow
down · line 10 - RMAta.tr, DI Length (11)
trur · line 13 - RMAplusDM, DI Length (11)
plus · line 14 - RMAminusDM, DI Length (11)
minus · line 15 - RMAmath.abs(plus - minus) / (sum == 0 ? 1 : sum), ADX Smoothing (11)
adx · line 17
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | buy | On | 25 |
| Open short short | sell | On | 28 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
No
No repainting patterns in the source, and the live replay matched history.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +8.5% | +102.5% | 6 | 50% | 5.98 | 2.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.3% | +5.5% | 4 | 50% | 1.27 | 1.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.0% | +9.8% | 6 | 33% | 0.63 | 0.3% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.0% | +8.4% | 4 | 50% | 0.62 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 3 | 67% | 8.22 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 3 | 33% | 0.23 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.0% | +148.3% | 4 | 25% | 0.61 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 3 | 67% | 0.49 | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 2 | 50% | $42,840.60 |
| Sideways market | 3 | 67% | $46,355.00 |
| Falling market | 1 | 0% | −$3,941.20 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
1.7%
The 95th percentile of the worst drawdown when the same 6 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.3% to 1.7%; the tick is what actually happened, 1.3%. Order luck alone moves it this much.
All 6 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 10 Feb 2024 47,132.80 | 25 Jun 2024 60,293.30 | 136 | −$13,160.50 |
| long | 25 Jun 2024 60,293.30 | 12 Nov 2024 88,648.00 | 140 | $28,354.70 |
| short | 12 Nov 2024 88,648.00 | 26 Feb 2025 88,680.40 | 106 | −$32.39 |
| long | 26 Feb 2025 88,680.40 | 15 Jul 2025 119,841.00 | 139 | $31,160.80 |
| short | 15 Jul 2025 119,841.00 | 2 Feb 2026 76,968.20 | 202 | $42,872.90 |
| long | 2 Feb 2026 76,968.20 | 21 Aug 2026 73,027.00 | 200 | −$3,941.20 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| DMI Strategy this page | — | v5 strategy | +8.5% | 6 | 2.7% |
| Simple and efficient 1h strategy by SoftKill21 | rma | v4 strategy | No trades on this market | ||
| Ichimoku + RSI Crypto trending strategy by exlux99 | rma | v4 strategy | No trades on this market | ||
| DI Crossing Daily Straregy HulkTrading by TheHulkTrading | rma | v4 strategy | +34.3% | 65 | 18.4% |
| Kimchi Premium Strategy by chanu_lev10k | rma | v5 strategy | No trades on this market | ||
| Infiten Slope Strategy by spiritualhealer117 | rma | v4 strategy | +47.2% | 26 | 35.5% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 6 before, 10 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯//Default value has been taken as 14 for DMI+ and 6 for RSI.-//@version=5+//@version=6strategy(title="DMI Strategy", overlay=false)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | Yes 1,000 bars in 22 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © email_analysts// This code gives indication on the chart to go long based on DMI and exit based on RSI. //Default value has been taken as 14 for DMI+ and 6 for RSI.//@version=5strategy(title="DMI Strategy", overlay=false)lensig = input.int(11, title="ADX Smoothing", minval=1, maxval=50)len = input.int(11, minval=1, title="DI Length")up = ta.change(high)down = -ta.change(low)plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)trur = ta.rma(ta.tr, len)plus = fixnan(100 * ta.rma(plusDM, len) / trur)minus = fixnan(100 * ta.rma(minusDM, len) / trur)sum = plus + minusadx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)//plot(adx, color=#F50057, title="ADX")plot(plus, color=color.green, title="+DI")plot(minus, color=color.red, title="-DI")hlineup = hline(40, color=#787B86)hlinelow = hline(10, color=#787B86)buy = plus < 10 and minus > 40if buy strategy.entry('long', strategy.long)sell = plus > 40 and minus < 10if sell strategy.entry('short', strategy.short)