Pine Script v4 · Strategy
DI Crossing Daily Straregy HulkTrading
A Pine Script v4 strategy built on Change (high), RMA (tr, 14) and Crossover (di_plus, di_minus). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 2 settings; defaults include ATR Multiplier 1 and Length di 14.
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 DI Crossing Daily Straregy HulkTrading repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 16 of 16 trades.
- How did DI Crossing Daily Straregy HulkTrading do on BTCUSDT 1D with default settings?
- +34.26%
- From 26 Jan 2024 to 21 Oct 2026, over 65 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can DI Crossing Daily Straregy HulkTrading be converted to Pine Script v5?
- Yes
- The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
- Does DI Crossing Daily Straregy HulkTrading use a stop loss?
- Yes
- strategy.exit sets a stop on line 25, 27.
- Does DI Crossing Daily Straregy HulkTrading run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 31 ms, in the browser.
BTCUSDT · 1D · default settings
- Change
- Change
- RMA
- RMA
- RMA
- Crossover
- Crossunder
- ATR
- ATR
- ATR
- ATR
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +34.26%
- $34,261.10
- Buy and hold
- +102.5%
- same period
- Closed trades
- 65
- 26 won · 38 lost
- Profitable
- 40.0%
- of closed trades
- Profit factor
- 1.38
- gross profit ÷ gross loss
- Max drawdown
- 18.44%
- −$22,978.20
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. 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.
-
Likely bug
rma(tr, 14) ignores the settings line 11
Line 11 hard-codes 14 where line 13 uses “Length di”. Changing those settings moves one band but not this one.
rma(tr, 14)rma(tr, length) -
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.
-
Note
Uses an argument v6 removed
when = on line 24, 26. 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 change → ta.change, rma → ta.rma, crossover → ta.crossover, crossunder → ta.crossunder, atr → ta.atr.
- 2 strategy calls use the when = argument (line 24, 26). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 65 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 9: change → ta.change
- Line 10: change → ta.change
- Line 11: range is reserved in v5: renamed range_
- Line 11: rma → ta.rma
- Line 11: tr → ta.tr
8 more edits
- Line 13: rma → ta.rma
- Line 14: rma → ta.rma
- Line 16: crossover → ta.crossover
- Line 17: crossunder → ta.crossunder
- Line 19: atr → ta.atr
- Line 20: atr → ta.atr
- Line 21: atr → ta.atr
- Line 22: atr → ta.atr
⋯// © TheHulkTrading-//@version=4+//@version=5strategy("DI Crossing Daily Straregy HulkTrading", overlay=true)⋯length = input(14, minval=1, title="Length di")-up = change(high)+up = ta.change(high)-down = -change(low)+down = -ta.change(low)-range = rma(tr, 14)+range_ = ta.rma(ta.tr, 14)//DI+ and DI- Calculations-di_plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, length) / range)+di_plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, length) / range_)-di_minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, length) / range)+di_minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, length) / range_)//Long and short conditions-longCond = crossover(di_plus,di_minus)+longCond = ta.crossover(di_plus,di_minus)-shortCond = crossunder(di_plus,di_minus) +shortCond = ta.crossunder(di_plus,di_minus) //Stop levels and take profits-stop_level_long = strategy.position_avg_price - atr_multiplier*atr(14)+stop_level_long = strategy.position_avg_price - atr_multiplier*ta.atr(14)-take_level_long = strategy.position_avg_price + 2*atr_multiplier*atr(14)+take_level_long = strategy.position_avg_price + 2*atr_multiplier*ta.atr(14)-stop_level_short = strategy.position_avg_price + atr_multiplier*atr(14)+stop_level_short = strategy.position_avg_price + atr_multiplier*ta.atr(14)-take_level_short = strategy.position_avg_price - 2*atr_multiplier*atr(14)+take_level_short = strategy.position_avg_price - 2*atr_multiplier*ta.atr(14)//Entries and exits ⋯Same 65 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 8: input() → input.int()
- Line 24: when = longCond → if block
- Line 26: when = shortCond → if block
⋯// ATR Multiplier. Recommended values between 1..4-atr_multiplier = input(1, minval=1, title="ATR Multiplier") +atr_multiplier = input.int(1, minval=1, title="ATR Multiplier") //Length of DI. Recommended default value = 14-length = input(14, minval=1, title="Length di")+length = input.int(14, minval=1, title="Length di")up = ta.change(high)⋯//Entries and exits -strategy.entry("Long", strategy.long, when=longCond)+if longCond+ strategy.entry("Long", strategy.long)strategy.exit("Close Long","Long", stop=stop_level_long, limit = take_level_long)-strategy.entry("Short", strategy.short, when=shortCond)+if shortCond+ strategy.entry("Short", strategy.short)strategy.exit("Close Short","Short", stop=stop_level_short, limit = take_level_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: 65 before, 56 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.
⋯// © TheHulkTrading-//@version=5+//@version=6strategy("DI Crossing Daily Straregy HulkTrading", overlay=true)⋯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 |
|---|---|---|---|
| ATR Multiplier | 1 | int · min 1 | stop_level_long take_level_long stop_level_short take_level_short |
| Length di | 14 | int · min 1 | di_plus di_minus |
What it calculates
- Change (
change,ta.changein v5)highup · line 9 - Change (
change,ta.changein v5)lowdown · line 10 - RMA (
rma,ta.rmain v5)tr, 14range · line 11 - RMA (
rma,ta.rmain v5)up > down and up > 0 ? up : 0, Length di (14)di_plus · line 13 - RMA (
rma,ta.rmain v5)down > up and down > 0 ? down : 0, Length di (14)di_minus · line 14 - Crossover (
crossover,ta.crossoverin v5)di_plus, di_minuslongCond · line 16 - Crossunder (
crossunder,ta.crossunderin v5)di_plus, di_minusshortCond · line 17 - ATR (
atr,ta.atrin v5)14stop_level_long · line 19 - ATR (
atr,ta.atrin v5)14take_level_long · line 20 - ATR (
atr,ta.atrin v5)14stop_level_short · line 21 - ATR (
atr,ta.atrin v5)14take_level_short · line 22
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 | longCond | On | 24 |
| Exit Close Long stop and limit | every bar | On | 25 |
| Open Short short | shortCond | On | 26 |
| Exit Close Short stop and limit | every bar | On | 27 |
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 | +34.3% | +102.5% | 65 | 40% | 1.38 | 18.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +7.4% | +5.5% | 84 | 38% | 1.23 | 6.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +2.5% | +9.8% | 49 | 43% | 1.76 | 0.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.1% | +8.4% | 82 | 28% | 0.90 | 0.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.3% | +16.7% | 70 | 43% | 2.51 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 75 | 36% | 1.17 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.1% | +148.3% | 86 | 28% | 0.91 | 0.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 84 | 33% | 1.14 | 0.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 25 | 28% | −$14,986.70 |
| Sideways market | 29 | 55% | $51,953.80 |
| Falling market | 11 | 27% | −$2,706.04 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
25.1%
The 95th percentile of the worst drawdown when the same 65 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 11.0% to 25.1%; the tick is what actually happened, 16.2%. Order luck alone moves it this much.
All 65 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 20 Mar 2024 61,937.40 | 21 Mar 2024 67,840.50 | 1 | −$5,903.10 |
| long | 26 Mar 2024 69,880.00 | 2 Apr 2024 69,649.80 | 7 | −$230.19 |
| short | 2 Apr 2024 69,649.80 | 7 Apr 2024 68,896.00 | 5 | $753.81 |
| long | 7 Apr 2024 68,896.00 | 12 Apr 2024 65,735.00 | 5 | −$3,160.96 |
| short | 13 Apr 2024 67,116.50 | 17 Apr 2024 59,807.80 | 4 | $7,308.69 |
| long | 16 May 2024 66,206.50 | 20 May 2024 71,312.40 | 4 | $5,105.86 |
| short | 12 Jun 2024 67,314.20 | 21 Jun 2024 63,394.80 | 9 | $3,919.45 |
| long | 16 Jul 2024 64,724.10 | 29 Jul 2024 69,459.80 | 13 | $4,735.71 |
| short | 2 Aug 2024 65,354.00 | 3 Aug 2024 60,147.80 | 1 | $5,206.20 |
| long | 24 Aug 2024 64,037.20 | 27 Aug 2024 61,404.60 | 3 | −$2,632.62 |
| short | 28 Aug 2024 59,415.00 | 6 Sep 2024 54,326.70 | 9 | $5,088.29 |
| long | 18 Sep 2024 60,314.00 | 23 Sep 2024 64,701.20 | 5 | $4,387.16 |
| short | 2 Oct 2024 60,804.90 | 6 Oct 2024 62,848.90 | 4 | −$2,044.03 |
| long | 8 Oct 2024 62,224.00 | 10 Oct 2024 60,636.00 | 2 | −$1,588.00 |
| short | 10 Oct 2024 60,636.00 | 11 Oct 2024 62,644.90 | 1 | −$2,008.94 |
| long | 12 Oct 2024 62,540.00 | 14 Oct 2024 62,870.00 | 2 | $330.03 |
| short | 14 Oct 2024 62,870.00 | 14 Oct 2024 64,507.70 | 0 | −$1,637.64 |
| long | 15 Oct 2024 66,084.00 | 28 Oct 2024 69,974.30 | 13 | $3,890.30 |
| short | 21 Dec 2024 97,805.40 | 6 Jan 2025 101,197.00 | 16 | −$3,391.40 |
| long | 7 Jan 2025 102,236.00 | 8 Jan 2025 96,954.60 | 1 | −$5,281.00 |
| short | 9 Jan 2025 95,060.60 | 15 Jan 2025 98,712.80 | 6 | −$3,652.19 |
| long | 18 Jan 2025 104,077.00 | 19 Jan 2025 100,320.00 | 1 | −$3,757.90 |
| short | 27 Jan 2025 102,620.00 | 3 Feb 2025 94,379.40 | 7 | $8,240.65 |
| long | 25 Mar 2025 87,498.20 | 27 Mar 2025 86,909.20 | 2 | −$588.99 |
| short | 27 Mar 2025 86,909.20 | 3 Apr 2025 82,516.30 | 7 | $4,392.89 |
| long | 3 Apr 2025 82,516.30 | 3 Apr 2025 82,516.30 | 0 | $0.00 |
| short | 7 Apr 2025 78,430.00 | 9 Apr 2025 82,249.40 | 2 | −$3,819.40 |
| long | 13 Apr 2025 85,276.90 | 22 Apr 2025 91,600.90 | 9 | $6,323.99 |
| short | 31 May 2025 103,985.00 | 4 Jun 2025 105,377.00 | 4 | −$1,391.43 |
| long | 4 Jun 2025 105,377.00 | 5 Jun 2025 104,697.00 | 1 | −$680.04 |
| short | 5 Jun 2025 104,697.00 | 9 Jun 2025 107,511.00 | 4 | −$2,814.09 |
| long | 10 Jun 2025 110,263.00 | 12 Jun 2025 107,385.00 | 2 | −$2,877.62 |
| short | 13 Jun 2025 105,672.00 | 16 Jun 2025 108,454.00 | 3 | −$2,781.78 |
| long | 30 Jun 2025 108,357.00 | 1 Jul 2025 107,147.00 | 1 | −$1,210.42 |
| short | 1 Jul 2025 107,147.00 | 3 Jul 2025 108,850.00 | 2 | −$1,703.08 |
| long | 3 Jul 2025 108,850.00 | 5 Jul 2025 107,984.00 | 2 | −$865.34 |
| short | 5 Jul 2025 107,984.00 | 7 Jul 2025 109,204.00 | 2 | −$1,219.60 |
| long | 7 Jul 2025 109,204.00 | 10 Jul 2025 114,218.00 | 3 | $5,014.40 |
| short | 2 Aug 2025 113,298.00 | 7 Aug 2025 115,960.00 | 5 | −$2,661.71 |
| long | 8 Aug 2025 117,472.00 | 13 Aug 2025 122,812.00 | 5 | $5,340.26 |
| short | 20 Aug 2025 112,873.00 | 22 Aug 2025 115,724.00 | 2 | −$2,850.92 |
| long | 23 Aug 2025 116,936.00 | 24 Aug 2025 113,920.00 | 1 | −$3,015.61 |
| short | 25 Aug 2025 113,494.00 | 1 Sep 2025 107,379.00 | 7 | $6,114.53 |
| long | 9 Sep 2025 112,065.00 | 16 Sep 2025 116,943.00 | 7 | $4,877.86 |
| short | 23 Sep 2025 112,651.00 | 30 Sep 2025 114,312.00 | 7 | −$1,660.98 |
| long | 30 Sep 2025 114,312.00 | 2 Oct 2025 119,363.00 | 2 | $5,051.52 |
| short | 11 Oct 2025 112,774.00 | 17 Oct 2025 104,305.00 | 6 | $8,469.97 |
| long | 27 Oct 2025 114,559.00 | 29 Oct 2025 110,820.00 | 2 | −$3,739.13 |
| short | 30 Oct 2025 110,021.00 | 4 Nov 2025 102,736.00 | 5 | $7,284.83 |
| long | 30 Dec 2025 87,237.10 | 5 Jan 2026 92,103.60 | 6 | $4,866.45 |
| short | 21 Jan 2026 88,427.70 | 23 Jan 2026 90,912.30 | 2 | −$2,484.59 |
| long | 5 Mar 2026 72,666.80 | 6 Mar 2026 69,061.00 | 1 | −$3,605.80 |
| short | 7 Mar 2026 68,114.00 | 10 Mar 2026 71,540.90 | 3 | −$3,426.85 |
| long | 11 Mar 2026 69,948.60 | 17 Mar 2026 75,951.80 | 6 | $6,003.12 |
| short | 23 Mar 2026 67,859.00 | 24 Mar 2026 70,906.40 | 1 | −$3,047.45 |
| long | 24 Mar 2026 70,906.40 | 27 Mar 2026 68,820.30 | 3 | −$2,086.14 |
| short | 27 Mar 2026 68,820.30 | 7 Apr 2026 68,853.70 | 11 | −$33.35 |
| long | 7 Apr 2026 68,853.70 | 13 Apr 2026 73,781.60 | 6 | $4,927.97 |
| short | 19 May 2026 77,001.90 | 21 May 2026 77,552.20 | 2 | −$550.36 |
| long | 21 May 2026 77,552.20 | 22 May 2026 75,593.20 | 1 | −$1,959.02 |
| short | 23 May 2026 75,539.50 | 25 May 2026 77,573.60 | 2 | −$2,034.08 |
| long | 20 Aug 2026 69,334.80 | 21 Aug 2026 73,027.00 | 1 | $3,692.24 |
| short | 14 Oct 2026 83,169.00 | 20 Oct 2026 81,938.40 | 6 | $1,230.62 |
| long | 20 Oct 2026 81,938.40 | 21 Oct 2026 83,028.10 | 1 | $1,089.75 |
| short | 21 Oct 2026 83,028.10 | 21 Oct 2026 84,017.80 | 0 | −$989.69 |
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 |
|---|---|---|---|---|---|
| DI Crossing Daily Straregy HulkTrading this page | — | v4 strategy | +34.3% | 65 | 18.4% |
| Strategy Myth-Busting #12 - OSGFC+SuperTrend - [MYN] by myncrypto | atr rma | v5 strategy | does not run in Zeal Terminal | ||
| Jigga - Survival Level by jigneshjc | rma atr | v5 strategy | No trades on this market | ||
| Nifty & BN 2 Candle Theory Back Testing and Alert Notification by abdullabashaa | rma atr | v5 strategy | −1.9% | 3 | 1.9% |
| Strategy Myth-Busting #8 - TrendSurfers+TrendOsc - [MYN] by myncrypto | atr rma | v5 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | Yes 1,000 bars in 31 ms | Not measured |
| PineTS | No 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/// © TheHulkTrading//@version=4strategy("DI Crossing Daily Straregy HulkTrading", overlay=true)// ATR Multiplier. Recommended values between 1..4atr_multiplier = input(1, minval=1, title="ATR Multiplier") //Length of DI. Recommended default value = 14length = input(14, minval=1, title="Length di")up = change(high)down = -change(low)range = rma(tr, 14)//DI+ and DI- Calculationsdi_plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, length) / range)di_minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, length) / range)//Long and short conditionslongCond = crossover(di_plus,di_minus)shortCond = crossunder(di_plus,di_minus) //Stop levels and take profitsstop_level_long = strategy.position_avg_price - atr_multiplier*atr(14)take_level_long = strategy.position_avg_price + 2*atr_multiplier*atr(14)stop_level_short = strategy.position_avg_price + atr_multiplier*atr(14)take_level_short = strategy.position_avg_price - 2*atr_multiplier*atr(14)//Entries and exits strategy.entry("Long", strategy.long, when=longCond)strategy.exit("Close Long","Long", stop=stop_level_long, limit = take_level_long)strategy.entry("Short", strategy.short, when=shortCond)strategy.exit("Close Short","Short", stop=stop_level_short, limit = take_level_short)