Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

DMI + HMA - No Risk Management

A Pine Script v4 strategy built on HMA (close, 29) and SMA (DX, 76). It has 2 order rules and no entry of its own. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.025% commission. 3 settings; defaults include Hull 1 length 29, Hull 2 length 2 and Length for DI 76.

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 + HMA - No Risk Management repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did DMI + HMA - No Risk Management do on BTCUSDT 1D with default settings?
−1.36%
From 26 Jan 2024 to 21 Oct 2026, over 2 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can DMI + HMA - No Risk Management be converted to Pine Script v5?
No
The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
Does DMI + HMA - No Risk Management use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does DMI + HMA - No Risk Management run in Zeal Terminal?
Yes
It compiles in 22 ms and runs 1,000 bars in 38 ms, in the browser.

BTCUSDT · 1D · default settings

  • DI+
  • DI-
  • ADX
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (3)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctDI+$102,886$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
−1.36%
−$1,364.54
Buy and hold
+102.5%
same period
Closed trades
2
1 won · 1 lost
Profitable
50.0%
of closed trades
Profit factor
0.29
gross profit ÷ gross loss
Max drawdown
28.77%
−$28,765.00

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long 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

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 35, 37. The upgraded version below moves each call inside an if block.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames max → math.max, abs → math.abs, hma → ta.hma, sma → ta.sma, crossover → ta.crossover.
  • 2 strategy calls use the when = argument (line 35, 37). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Differs

Trades differ: 2 before, 2 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 6: input(type = input.integer) → input.int()
  • Line 7: input(type = input.integer) → input.int()
  • Line 8: input(type = input.integer) → input.int()
  • Line 10: max → math.max
  • Line 10: max → math.max
10 more edits
  • Line 10: abs → math.abs
  • Line 10: abs → math.abs
  • Line 11: max → math.max
  • Line 12: max → math.max
  • Line 20: hma → ta.hma
  • Line 21: hma → ta.hma
  • Line 24: abs → math.abs
  • Line 25: sma → ta.sma
  • Line 31: crossover → ta.crossover
  • Line 32: crossover → ta.crossover
⋯// © Tuned_Official-//@version=4+//@version=5strategy(title="DMI + HMA - No Risk Management", overlay = false, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.025)//Inputs-hullLen1 = input(title="Hull 1 length", type=input.integer, defval=29)+hullLen1 = input.int(title="Hull 1 length", defval=29)-hullLen2 = input(title="Hull 2 length", type=input.integer, defval=2)+hullLen2 = input.int(title="Hull 2 length", defval=2)-len = input(title="Length for DI", type=input.integer, defval=76)+len = input.int(title="Length for DI", defval=76)//Calculations-TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))+TrueRange = math.max(math.max(high-low, math.abs(high-nz(close[1]))), math.abs(low-nz(close[1])))-DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0+DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? math.max(high-nz(high[1]), 0): 0-DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0+DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? math.max(nz(low[1])-low, 0): 0SmoothedTrueRange = 0.0⋯//Indicators-fasthull = hma(close, hullLen1)+fasthull = ta.hma(close, hullLen1)-slowhull = hma(close, hullLen2)+slowhull = ta.hma(close, hullLen2)DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100-DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100+DX = math.abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100-ADX = sma(DX, len)+ADX = ta.sma(DX, len)//Plots⋯//conditions-go_long = crossover(DIPlus, DIMinus) and fasthull > slowhull //crossover(fasthull, slowhull) and DIPlus > DIMinus+go_long = ta.crossover(DIPlus, DIMinus) and fasthull > slowhull //crossover(fasthull, slowhull) and DIPlus > DIMinus-go_short = crossover(DIMinus, DIPlus) and fasthull < slowhull //crossunder(fasthull, slowhull) and DIMinus > DIPlus+go_short = ta.crossover(DIMinus, DIPlus) and fasthull < slowhull //crossunder(fasthull, slowhull) and DIMinus > DIPlus//Entry⋯

Clean v5

Verified

Same 2 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 35: when = go_long → if block
  • Line 37: when = go_short → if block
⋯if strategy.position_size < 0 or strategy.position_size == 0-    strategy.order("long", strategy.long, when=go_long)+    if go_long+        strategy.order("long", strategy.long)if strategy.position_size > 0 or strategy.position_size == 0-    strategy.order("Short", strategy.short, when=go_short)+    if go_short+        strategy.order("Short", strategy.short)

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: 2 before, 4 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.

⋯// © Tuned_Official-//@version=5+//@version=6strategy(title="DMI + HMA - No Risk Management", overlay = false, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.025)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Hull 1 length29int (written input.integer)fasthull
Hull 2 length2int (written input.integer)slowhull
Length for DI76int (written input.integer)SmoothedTrueRange SmoothedDirectionalMovementPlus SmoothedDirectionalMovementMinus ADX

What it calculates

  • HMA (hma, ta.hma in v5)close, Hull 1 length (29)fasthull · line 20
  • HMA (hma, ta.hma in v5)close, Hull 2 length (2)slowhull · line 21
  • SMA (sma, ta.sma in v5)DX, Length for DI (76)ADX · line 25

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.

closecloseprice datahullLen1Hull 1 lengthsetting · 29hullLen2Hull 2 lengthsetting · 2lenLength for DIsetting · 76lowlowprice datahighhighprice datafasthullHMA→ fasthullslowhullHMA→ slowhullADXSMA→ ADXTrueRangeTrueRangevalueDirectionalMovementPlus, DirectionalMovementMinusDirectionalMovementPlus…2 valuesSmoothedTrueRangeSmoothedTrueRangevalueSmoothedDirectionalMovementPlusSmoothedDirectionalMove…valueSmoothedDirectionalMovementMinusSmoothedDirectionalMove…valueDIPlusDIPlusvalueDIMinusDIMinusvalueDXDXvaluego_longgo_longconditiongo_shortgo_shortconditionorder:longorder longstrategy.orderorder:Shortorder Shortstrategy.orderplot:27DI+plotplot:28DI-plotplot:29ADXplot

Order rules

OrderFires whenBy defaultLine
order long longgo_longcrossover(DIPlus, DIMinus) and fasthull > slowhullOn35
order Short shortgo_shortcrossover(DIMinus, DIPlus) and fasthull < slowhullOn37

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D−1.4%+102.5%250%0.2928.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−2.3%+5.5%250%0.0013.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.5%+9.8%10%0.0017.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+8.7%+8.4%1100%1,370,800.0012.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%00%0.00104.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−1.2%+21.5%367%0.5513.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.0%+148.3%00%0.0031.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+2.3%+17.1%1100%1,968.076.1%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 barsTradesWonP&L
Rising market0—$0.00
Sideways market250%−$1,340.69
Falling market0—$0.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

1.9%

The 95th percentile of the worst drawdown when the same 2 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.9% to 1.9%; the tick is what actually happened, 1.9%. Order luck alone moves it this much.

0%2%
All 2 trades
SideEntryExitBarsP&L
short29 Apr 2025 95,011.207 May 2025 96,834.008−$1,893.95
short29 Apr 2025 95,011.2015 May 2026 81,090.00381$553.26

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
DMI + HMA - No Risk Management this page—v4 strategy−1.4%228.8%
VOLLY PRICE CONVERGE by Celarsma hmav5 strategy+41.2%7522.4%
Extremely high win rate FOREX swing strategy by exlux99sma hmav4 strategyNo trades on this market
Smoothed Heikin Ashi Trend on Chart - TraderHalai BACKTEST by TraderHalaisma hmav5 strategy+1.3%1135.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 22 msYes 1,000 bars in 38 msNot measured
PineTSNo v5 and v6 only—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. PineTS runs Pine Script v5 and v6 only.

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/// © Tuned_Official//@version=4strategy(title="DMI + HMA - No Risk Management", overlay = false, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.025)//InputshullLen1 = input(title="Hull 1 length", type=input.integer, defval=29)hullLen2 = input(title="Hull 2 length", type=input.integer, defval=2)len = input(title="Length for DI", type=input.integer, defval=76)//CalculationsTrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0SmoothedTrueRange = 0.0SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRangeSmoothedDirectionalMovementPlus = 0.0SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlusSmoothedDirectionalMovementMinus = 0.0SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus//Indicatorsfasthull = hma(close, hullLen1)slowhull = hma(close, hullLen2)DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100ADX = sma(DX, len)//Plotsplot(DIPlus, color=color.green, title="DI+")plot(DIMinus, color=color.red, title="DI-")plot(ADX, color=color.black, title="ADX")//conditionsgo_long = crossover(DIPlus, DIMinus) and fasthull > slowhull //crossover(fasthull, slowhull) and DIPlus > DIMinusgo_short = crossover(DIMinus, DIPlus) and fasthull < slowhull //crossunder(fasthull, slowhull) and DIMinus > DIPlus//Entryif strategy.position_size < 0 or strategy.position_size == 0    strategy.order("long", strategy.long, when=go_long)if strategy.position_size > 0 or strategy.position_size == 0    strategy.order("Short", strategy.short, when=go_short)