Pine Script v4 · Strategy
Rising ADX strategy
A Pine Script v4 strategy built on SMA or EMA or WMA or HMA (close, 20), Change (_high) and RMA (_tr, len). It has 4 order rules, 2 entries among them, and trades no side with the default settings; 2 entries are switched off until a setting enables them. Exits wait for a signal; there is no stop loss. Each trade is 25 contracts and pays no commission. 8 settings; defaults include ADX Length 14, threshold 10 and 1=SMA, 2=EMA, 3=WMA, 4=HullMA 2.
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 Rising ADX strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Rising ADX strategy do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
- Can Rising ADX strategy be converted to Pine Script v5?
- Not tested
- The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
- Does Rising ADX strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Rising ADX strategy run in Zeal Terminal?
- Yes
- It compiles in 27 ms and runs 1,000 bars in 97 ms, in the browser.
BTCUSDT · 1D · default settings
- HLine
- ADX
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
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.
-
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.
-
Note
The long side is off by default line 40
Its orders only fire after “Long side” is switched on. The figures on this page cover trades only.
-
Note
The short side is off by default line 47
Its orders only fire after “Short side” is switched on. The figures on this page cover trades only.
-
Note
Uses an argument v6 removed
when = on line 40, 42, 47, 49. The upgraded version below moves each call inside an if block.
-
Note
Uses long =, which v5 renamed line 40
long = on line 40, 47. v5 writes it as direction = strategy.long or strategy.short.
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 sma → ta.sma, ema → ta.ema, wma → ta.wma, hma → ta.hma, change → ta.change, rma → ta.rma, abs → math.abs, rising → ta.rising, falling → ta.falling.
- 4 strategy calls use the when = argument (line 40, 42, 47, 49). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 3: //@version=4 → //@version=5
- Line 11: sma → ta.sma
- Line 11: ema → ta.ema
- Line 11: wma → ta.wma
- Line 11: hma → ta.hma
- Line 14: sma → ta.sma
25 more edits
- Line 14: ema → ta.ema
- Line 14: wma → ta.wma
- Line 14: hma → ta.hma
- Line 18: change → ta.change
- Line 19: change → ta.change
- Line 22: rma → ta.rma
- Line 24: rma → ta.rma
- Line 25: rma → ta.rma
- Line 30: rma → ta.rma
- Line 30: abs → math.abs
- Line 31: tr → ta.tr
- Line 32: tr → ta.tr
- Line 33: tr → ta.tr
- Line 34: rising → ta.rising
- Line 34: falling → ta.falling
- Line 36: rising → ta.rising
- Line 36: falling → ta.falling
- Line 40: long = true → direction = strategy.long
- Line 41: rising → ta.rising
- Line 41: falling → ta.falling
- Line 43: rising → ta.rising
- Line 43: falling → ta.falling
- Line 47: long = false → direction = strategy.short
- Line 48: rising → ta.rising
- Line 48: falling → ta.falling
⋯// © dhilipthegreat-//@version=4+//@version=5//Rising ADX strategy⋯malen=input(20, title="Moving average 1 ",minval=1, maxval=50)-avg = atype == 1 ? sma(close,malen) : atype == 2 ? ema(close,malen) : atype == 3 ? wma(close,malen) : atype == 4 ? hma(close,malen) : na+avg = atype == 1 ? ta.sma(close,malen) : atype == 2 ? ta.ema(close,malen) : atype == 3 ? ta.wma(close,malen) : atype == 4 ? ta.hma(close,malen) : naatype2 = input(2,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA")malen2=input(20, title="Moving average 2",minval=1, maxval=200)-avg2 = atype2 == 1 ? sma(close,malen2) : atype2 == 2 ? ema(close,malen2) : atype2 == 3 ? wma(close,malen2) : atype2 == 4 ? hma(close,malen2) : na+avg2 = atype2 == 1 ? ta.sma(close,malen2) : atype2 == 2 ? ta.ema(close,malen2) : atype2 == 3 ? ta.wma(close,malen2) : atype2 == 4 ? ta.hma(close,malen2) : na//ADX&DI⋯dirmov(len,_high,_low,_tr) =>- up = change(_high)+ up = ta.change(_high)- down = -change(_low)+ 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)- truerange = rma(_tr, len)+ truerange = ta.rma(_tr, len) - plus = fixnan(100 * rma(plusDM, len) / truerange)+ plus = fixnan(100 * ta.rma(plusDM, len) / truerange)- minus = fixnan(100 * rma(minusDM, len) / truerange)+ minus = fixnan(100 * ta.rma(minusDM, len) / truerange) [plus, minus]⋯ sum = plus + minus- adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)+ adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)-[plus, minus] = dirmov(dilen,high,low,tr)+[plus, minus] = dirmov(dilen,high,low,ta.tr)-sig = adx(dilen, adxlen,high,low,tr)+sig = adx(dilen, adxlen,high,low,ta.tr)-prev_sig = adx(dilen, adxlen,high[1],low[1],tr)+prev_sig = adx(dilen, adxlen,high[1],low[1],ta.tr)-plot(sig ? sig : na, color = rising(sig, 1) ? color.lime : falling(sig, 1) ? color.orange : color.purple, title="ADX",linewidth=2)+plot(sig ? sig : na, color = ta.rising(sig, 1) ? color.lime : ta.falling(sig, 1) ? color.orange : color.purple, title="ADX",linewidth=2)//////-longCondition= sig > threshold and rising(sig, 1) and falling(prev_sig, 1) and close > avg and close > avg2+longCondition= sig > threshold and ta.rising(sig, 1) and ta.falling(prev_sig, 1) and close > avg and close > avg2barcolor(longCondition ? color.yellow: na)⋯if Long_side- strategy.entry(id="Long", long=true, when= longCondition and strategy.position_size<1)+ strategy.entry(id="Long", direction = strategy.long, when= longCondition and strategy.position_size<1)- exitCondition= (rising(prev_sig, 1) and falling(sig, 1)) or close < avg and close < avg2+ exitCondition= (ta.rising(prev_sig, 1) and ta.falling(sig, 1)) or close < avg and close < avg2 strategy.close(id="Long",comment="L exit", qty=strategy.position_size , when= exitCondition) //close all-shortCondition= sig > threshold and rising(sig, 1) and falling(prev_sig, 1) and close < avg and close < avg2+shortCondition= sig > threshold and ta.rising(sig, 1) and ta.falling(prev_sig, 1) and close < avg and close < avg2barcolor(shortCondition ? color.gray: na)⋯if Short_side- strategy.entry(id="Short", long=false, when= shortCondition and strategy.position_size<1)+ strategy.entry(id="Short", direction = strategy.short, when= shortCondition and strategy.position_size<1)- sell_exitCondition= (rising(prev_sig, 1) and falling(sig, 1)) or close > avg and close > avg2+ sell_exitCondition= (ta.rising(prev_sig, 1) and ta.falling(sig, 1)) or close > avg and close > avg2 strategy.close(id="Short",comment="S exit", qty=strategy.position_size , when= sell_exitCondition) //close all⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 6: input() → input.int()
- Line 7: input() → input.int()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 12: input() → input.int()
- Line 13: input() → input.int()
6 more edits
- Line 38: input() → input.bool()
- Line 40: when = longCondition and strategy.position_size<1 → if block
- Line 42: when = exitCondition → if block
- Line 45: input() → input.bool()
- Line 47: when = shortCondition and strategy.position_size<1 → if block
- Line 49: when = sell_exitCondition → if block
⋯strategy(title="Rising ADX strategy", overlay=false,pyramiding=25, default_qty_type=strategy.fixed, default_qty_value=25, initial_capital=100000, currency=currency.USD)-adxlen = input(14, title="ADX Length", minval=1)+adxlen = input.int(14, title="ADX Length", minval=1)-threshold = input(10, title="threshold", minval=5)+threshold = input.int(10, title="threshold", minval=5)hline(threshold, color=color.black, linestyle=hline.style_dashed)-atype = input(2,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA")+atype = input.int(2,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA")-malen=input(20, title="Moving average 1 ",minval=1, maxval=50)+malen=input.int(20, title="Moving average 1 ",minval=1, maxval=50)avg = atype == 1 ? ta.sma(close,malen) : atype == 2 ? ta.ema(close,malen) : atype == 3 ? ta.wma(close,malen) : atype == 4 ? ta.hma(close,malen) : na-atype2 = input(2,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA")+atype2 = input.int(2,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA")-malen2=input(20, title="Moving average 2",minval=1, maxval=200)+malen2=input.int(20, title="Moving average 2",minval=1, maxval=200)avg2 = atype2 == 1 ? ta.sma(close,malen2) : atype2 == 2 ? ta.ema(close,malen2) : atype2 == 3 ? ta.wma(close,malen2) : atype2 == 4 ? ta.hma(close,malen2) : na⋯barcolor(longCondition ? color.yellow: na)-Long_side = input(false, "Long side")+Long_side = input.bool(false, "Long side")if Long_side- strategy.entry(id="Long", direction = strategy.long, when= longCondition and strategy.position_size<1)+ if longCondition and strategy.position_size<1+ strategy.entry(id="Long", direction = strategy.long) exitCondition= (ta.rising(prev_sig, 1) and ta.falling(sig, 1)) or close < avg and close < avg2- strategy.close(id="Long",comment="L exit", qty=strategy.position_size , when= exitCondition) //close all+ if exitCondition+ strategy.close(id="Long",comment="L exit", qty=strategy.position_size ) //close allshortCondition= sig > threshold and ta.rising(sig, 1) and ta.falling(prev_sig, 1) and close < avg and close < avg2barcolor(shortCondition ? color.gray: na)-Short_side = input(false, "Short side")+Short_side = input.bool(false, "Short side")if Short_side- strategy.entry(id="Short", direction = strategy.short, when= shortCondition and strategy.position_size<1)+ if shortCondition and strategy.position_size<1+ strategy.entry(id="Short", direction = strategy.short) sell_exitCondition= (ta.rising(prev_sig, 1) and ta.falling(sig, 1)) or close > avg and close > avg2- strategy.close(id="Short",comment="S exit", qty=strategy.position_size , when= sell_exitCondition) //close all+ if sell_exitCondition+ strategy.close(id="Short",comment="S exit", qty=strategy.position_size ) //close allbarcolor(strategy.position_size>1 ? color.lime: na)⋯Does it run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © dhilipthegreat-//@version=5+//@version=6//Rising ADX strategy⋯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 Length | 14 | int · min 1 | adx sig prev_sig |
| threshold | 10 | int · min 5 | longCondition shortCondition hline |
| 1=SMA, 2=EMA, 3=WMA, 4=HullMA | 2 | int · min 1 · max 7 | avg |
| Moving average 1 | 20 | int · min 1 · max 50 | avg |
| 1=SMA, 2=EMA, 3=WMA, 4=HullMA | 2 | int · min 1 · max 7 | avg2 |
| Moving average 2 | 20 | int · min 1 · max 200 | avg2 |
| Long side | false | bool | entry Long close Long line 39 |
| Short side | false | bool | entry Short close Short line 46 |
What it calculates
- SMA / EMA / WMA / HMA (
sma,ta.smain v5)close, Moving average 1 (20)avg · line 11 - SMA / EMA / WMA / HMA (
sma,ta.smain v5)close, Moving average 2 (20)avg2 · line 14 - Change (
change,ta.changein v5)_highup · line 18 - Change (
change,ta.changein v5)_lowdown · line 19 - RMA (
rma,ta.rmain v5)_tr, lentruerange · line 22 - RMA (
rma,ta.rmain v5)abs(plus - minus) / (sum == 0 ? 1 : sum), ADX Length (14)adx · line 30
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 | longCondition and strategy.position_size<1 | Off “Long side” | 40 |
| Close Long | exitCondition(rising(prev_sig, 1) and falling(sig, 1)) or close < avg and close < avg2 | Off “Long side” | 42 |
| Open Short short | shortCondition and strategy.position_size<1 | Off “Short side” | 47 |
| Close Short | sell_exitCondition(rising(prev_sig, 1) and falling(sig, 1)) or close > avg and close > avg2 | Off “Short side” | 49 |
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.
- 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 | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
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 |
|---|---|---|---|---|---|
| Rising ADX strategy this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| TEMA-DEMA-HMA Strategy by Tuned_Official | ema wma rising falling | v4 strategy | +73.8% | 4 | 30.6% |
| Smoothed Heikin Ashi Trend on Chart - TraderHalai BACKTEST by TraderHalai | sma ema hma rma | v5 strategy | +1.3% | 113 | 5.6% |
| Strategy Myth-Busting #13 - MultiEMA+BXTrender - [SP-MYN] by myncrypto | ema rma rising falling | v5 strategy | −0.3% | 2 | 0.3% |
| SPX Scalping Strategy by connor2279 | sma ema wma rma | v5 strategy | +1.5% | 109 | 5.0% |
| MACD Willy Strategy by PtGambler | rma sma ema wma | v5 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 27 ms | With a workaround 1,000 bars in 97 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 40, 47) so the engine trades the way the script says.
“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/// © dhilipthegreat//@version=4//Rising ADX strategystrategy(title="Rising ADX strategy", overlay=false,pyramiding=25, default_qty_type=strategy.fixed, default_qty_value=25, initial_capital=100000, currency=currency.USD)adxlen = input(14, title="ADX Length", minval=1)threshold = input(10, title="threshold", minval=5)hline(threshold, color=color.black, linestyle=hline.style_dashed)atype = input(2,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA")malen=input(20, title="Moving average 1 ",minval=1, maxval=50)avg = atype == 1 ? sma(close,malen) : atype == 2 ? ema(close,malen) : atype == 3 ? wma(close,malen) : atype == 4 ? hma(close,malen) : naatype2 = input(2,minval=1,maxval=7,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA")malen2=input(20, title="Moving average 2",minval=1, maxval=200)avg2 = atype2 == 1 ? sma(close,malen2) : atype2 == 2 ? ema(close,malen2) : atype2 == 3 ? wma(close,malen2) : atype2 == 4 ? hma(close,malen2) : na//ADX&DIdilen = 14dirmov(len,_high,_low,_tr) => up = change(_high) down = -change(_low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) truerange = rma(_tr, len) plus = fixnan(100 * rma(plusDM, len) / truerange) minus = fixnan(100 * rma(minusDM, len) / truerange) [plus, minus]adx(dilen, adxlen,_high,_low,_tr) => [plus, minus] = dirmov(dilen,_high,_low,_tr) sum = plus + minus adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)[plus, minus] = dirmov(dilen,high,low,tr)sig = adx(dilen, adxlen,high,low,tr)prev_sig = adx(dilen, adxlen,high[1],low[1],tr)plot(sig ? sig : na, color = rising(sig, 1) ? color.lime : falling(sig, 1) ? color.orange : color.purple, title="ADX",linewidth=2)//////longCondition= sig > threshold and rising(sig, 1) and falling(prev_sig, 1) and close > avg and close > avg2barcolor(longCondition ? color.yellow: na)Long_side = input(false, "Long side")if Long_side strategy.entry(id="Long", long=true, when= longCondition and strategy.position_size<1) exitCondition= (rising(prev_sig, 1) and falling(sig, 1)) or close < avg and close < avg2 strategy.close(id="Long",comment="L exit", qty=strategy.position_size , when= exitCondition) //close allshortCondition= sig > threshold and rising(sig, 1) and falling(prev_sig, 1) and close < avg and close < avg2barcolor(shortCondition ? color.gray: na)Short_side = input(false, "Short side")if Short_side strategy.entry(id="Short", long=false, when= shortCondition and strategy.position_size<1) sell_exitCondition= (rising(prev_sig, 1) and falling(sig, 1)) or close > avg and close > avg2 strategy.close(id="Short",comment="S exit", qty=strategy.position_size , when= sell_exitCondition) //close allbarcolor(strategy.position_size>1 ? color.lime: na)bgcolor(strategy.position_size>1 ? color.lime: na)barcolor(strategy.position_size<0 ? color.orange: na)bgcolor(strategy.position_size<0 ? color.orange: na)