Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Ichimoku Cloud and ADX with Trailing Stop Loss (by Coinrule)

A Pine Script v5 strategy built on DMI (14, 14). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 30% of equity and pays 0.1% commission. 10 settings; defaults include Tenkan-Sen Bars 9, Kijun-Sen Bars 26 and Senkou-Span B Bars 52.

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 Ichimoku Cloud and ADX with Trailing Stop Loss (by Coinrule) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 12 of 12 trades.
How did Ichimoku Cloud and ADX with Trailing Stop Loss (by Coinrule) do on BTCUSDT 1D with default settings?
−0.06%
From 26 Jan 2024 to 21 Oct 2026, over 51 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Ichimoku Cloud and ADX with Trailing Stop Loss (by Coinrule) run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L34:C85: 'fill' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download.
Does Ichimoku Cloud and ADX with Trailing Stop Loss (by Coinrule) use a stop loss?
Yes
strategy.exit sets a stop on line 65.
Does Ichimoku Cloud and ADX with Trailing Stop Loss (by Coinrule) run in Zeal Terminal?
Yes
It compiles in 16 ms and runs 1,000 bars in 58 ms, in the browser.

BTCUSDT · 1D · default settings

  • Tenkan-Sen
  • Kijun-Sen
  • Chikou-Span
  • Senkou-Span A
  • Senkou-Span B
  • 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 (10)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$999$2,025Equity from $1,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
−0.06%
−$0.58
Buy and hold
+102.5%
same period
Closed trades
51
18 won · 33 lost
Profitable
35.3%
of closed trades
Profit factor
1.00
gross profit ÷ gross loss
Max drawdown
8.13%
−$83.89

One run with the author's default settings, $1,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

    2 settings do nothing

    “Show Date Range”, “Short Entry” are declared but never read.

  • 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 64. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
Show Date Rangetrueboolunused
Tenkan-Sen Bars9int · min 1tenkan
Kijun-Sen Bars26int · min 1kijun
Senkou-Span B Bars52int · min 1senkouB
Chikou-Span Offset26int · min 1cs_cross_bull cs_cross_bear Chikou-Span
Senkou-Span Offset26int · min 1Senkou-Span A Senkou-Span B ss_high ss_low
Long Entrytrueboolentry Long
Short Entrytrueboolunused
Trail Long Loss (%)3float · min 0.0 · step 0.1longStopPrice stopValue
Trail Short Loss (%)3float · min 0.0 · step 0.1shortStopPrice stopValue

What it calculates

  • DMI14, 14pos_dm · line 38
  • DMI14, 14neg_dm · line 38
  • DMI14, 14avg_dm · line 38

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.

high · low · closehigh · low · closeprice datats_barsTenkan-Sen Barssetting · 9ks_barsKijun-Sen Barssetting · 26ssb_barsSenkou-Span B Barssetting · 52ss_offsetSenkou-Span Offsetsetting · 26closecloseprice datashortTrailPercTrail Short Loss (%)setting · 3timetimeprice datacs_offsetChikou-Span Offsetsetting · 26longTrailPercTrail Long Loss (%)setting · 3pos_dmDMI→ pos_dmneg_dmDMI→ neg_dmavg_dmDMI→ avg_dmtenkantenkanvaluekijunkijunvaluesenkouAsenkouAvaluesenkouBsenkouBvaluess_high, ss_lowss_high · ss_low2 valuesstopValuestopValuevaluetimePeriodtimePeriodconditiontk_cross_bull, tk_cross_beartk_cross_bull · tk_cros…2 conditionscs_cross_bull, cs_cross_bearcs_cross_bull · cs_cros…2 conditionsprice_above_kumo, price_below_kumoprice_above_kumo · pric…2 conditionsbullishbullishconditionbearishbearishconditionlongStopPricelongStopPriceconditionshortStopPriceshortStopPriceconditionentry:LongOpen Longstrategy.entryexit:Longexit Longstrategy.exitplot:29Tenkan-Senplotplot:30Kijun-Senplotplot:31Chikou-Spanplotplot:32Senkou-Span Aplotplot:33Senkou-Span Bplotfill:Cloud colorCloud colorfill

Order rules

OrderFires whenBy defaultLine
Open Long longbullish and long_entry and timePeriodOn64
Exit Long stop and limitevery barOn65

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.

12/12trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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−0.1%+102.5%5135%1.008.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.9%+5.5%1520%0.885.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.0%+9.8%5639%1.0014.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.8%+8.4%2133%1.085.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+3.1%+16.7%7141%1.0517.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+3.5%+21.5%2330%1.305.3%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+16.9%+148.3%5444%1.538.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.8%+17.1%1828%1.226.8%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 market2227%$30.14
Sideways market2741%−$39.25
Falling market250%$8.53

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

How bad could the drawdown be?

13.9%

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

0%16%
All 51 trades
SideEntryExitBarsP&L
long11 Apr 2024 70,006.2013 Apr 2024 65,103.002−$21.57
long17 May 2024 67,024.0021 May 2024 69,303.204$9.38
long21 May 2024 70,148.3023 May 2024 67,091.602−$13.48
long23 May 2024 67,969.6028 May 2024 67,353.305−$3.23
long28 May 2024 68,398.407 Jun 2024 68,974.8010$1.87
long7 Jun 2024 69,355.6011 Jun 2024 67,558.704−$8.13
long19 Jul 2024 66,660.0023 Jul 2024 66,120.404−$2.92
long23 Jul 2024 65,936.0030 Jul 2024 66,202.407$0.59
long30 Jul 2024 66,188.001 Aug 2024 62,689.202−$15.81
long20 Sep 2024 63,201.1030 Sep 2024 63,882.3010$2.49
long30 Sep 2024 63,327.609 Oct 2024 60,935.309−$11.30
long19 Oct 2024 68,378.0021 Oct 2024 66,961.002−$6.38
long21 Oct 2024 67,377.5023 Oct 2024 65,403.202−$8.73
long23 Oct 2024 66,668.6025 Oct 2024 66,152.302−$2.69
long25 Oct 2024 66,698.3031 Oct 2024 70,554.306$15.37
long31 Oct 2024 70,292.004 Nov 2024 67,411.104−$12.04
long4 Nov 2024 67,850.0012 Nov 2024 85,988.608$73.36
long12 Nov 2024 87,952.0014 Nov 2024 87,663.902−$1.57
long14 Nov 2024 87,325.6024 Nov 2024 95,925.2010$28.75
long3 Dec 2024 95,849.705 Dec 2024 95,629.702−$1.32
long5 Dec 2024 96,945.609 Dec 2024 98,076.304$2.96
long9 Dec 2024 97,276.5018 Dec 2024 102,950.009$17.29
long18 Dec 2024 100,204.0020 Dec 2024 94,538.002−$18.28
long22 Jan 2025 103,707.0027 Jan 2025 101,724.005−$6.48
long22 Apr 2025 93,443.005 May 2025 93,980.5013$1.14
long5 May 2025 94,733.7012 May 2025 101,665.007$21.72
long12 May 2025 102,791.0019 May 2025 103,261.007$0.80
long19 May 2025 105,574.0023 May 2025 108,345.004$7.56
long23 May 2025 107,318.0029 May 2025 106,152.006−$4.04
long29 May 2025 105,590.005 Jun 2025 102,682.007−$9.24
long2 Jul 2025 108,850.0015 Jul 2025 116,246.0013$20.46
long15 Jul 2025 117,758.0025 Jul 2025 116,356.0010−$4.40
long25 Jul 2025 117,614.0030 Jul 2025 115,833.005−$5.40
long30 Jul 2025 117,840.002 Aug 2025 112,291.003−$15.38
long12 Aug 2025 120,134.0014 Aug 2025 119,607.002−$1.97
long14 Aug 2025 118,295.0019 Aug 2025 113,883.005−$12.11
long18 Sep 2025 117,074.0022 Sep 2025 112,215.004−$13.25
long5 Oct 2025 123,482.007 Oct 2025 120,919.002−$6.84
long7 Oct 2025 121,333.0010 Oct 2025 119,607.003−$4.84
long14 Jan 2026 96,951.8019 Jan 2026 92,736.605−$13.51
long15 Apr 2026 74,810.0019 Apr 2026 74,759.804−$0.78
long19 Apr 2026 73,801.8028 Apr 2026 76,297.809$9.32
long28 Apr 2026 76,342.8013 May 2026 79,743.8015$12.58
long13 May 2026 79,313.6016 May 2026 78,657.303−$3.08
long16 May 2026 78,148.1023 May 2026 75,287.107−$11.52
long19 Aug 2026 69,334.8023 Aug 2026 75,987.904$27.72
long23 Aug 2026 77,734.0028 Aug 2026 77,842.105−$0.19
long28 Aug 2026 77,845.904 Sep 2026 78,832.307$3.24
long12 Sep 2026 77,278.7015 Sep 2026 75,843.503−$6.26
long24 Sep 2026 84,410.207 Oct 2026 83,934.1013−$2.31
long7 Oct 2026 83,321.8013 Oct 2026 81,259.906−$8.07

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
Ichimoku Cloud and ADX with Trailing Stop Loss (by Coinrule) this page—v5 strategy−0.1%518.1%
Ichimoku Cloud with ADX (By Coinrule) by Coinruledmiv5 strategy−16.8%621.9%
ADX and DMI by Zeal Terminaldmiv5 indicatorindicator

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.

  • 1 strategy call uses the when = argument (line 64). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 3 settings use the untyped input() (line 12, 20, 21). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 12: input() → input.bool()
  • Line 20: input() → input.bool()
  • Line 21: input() → input.bool()
  • Line 64: when = bullish and long_entry and timePeriod → if block
⋯         commission_value=0.1)-showDate = input(defval=true, title='Show Date Range')+showDate = input.bool(defval=true, title='Show Date Range')timePeriod = time >= timestamp(syminfo.timezone, 2018, 1, 1, 0, 0)⋯ss_offset = input.int(26, minval=1, title='Senkou-Span Offset')-long_entry = input(true, title='Long Entry')+long_entry = input.bool(true, title='Long Entry')-short_entry = input(true, title='Short Entry')+short_entry = input.bool(true, title='Short Entry')middle(len) => math.avg(ta.lowest(len), ta.highest(len))⋯    999999-strategy.entry('Long', strategy.long, when=bullish and long_entry and timePeriod)+if bullish and long_entry and timePeriod+    strategy.entry('Long', strategy.long)strategy.exit('Long', stop = longStopPrice, limit = shortStopPrice)⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L34:C85: 'fill' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Coinrule-//@version=5+//@version=6strategy('Ichimoku Cloud with ADX with Trailing Stop Loss',⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 16 msYes 1,000 bars in 58 msNot measured
PineTSNot testedNot testedNot 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/// © Coinrule//@version=5strategy('Ichimoku Cloud with ADX with Trailing Stop Loss',         overlay=true,         initial_capital=1000,         process_orders_on_close=true,         default_qty_type=strategy.percent_of_equity,         default_qty_value=30,         commission_type=strategy.commission.percent,         commission_value=0.1)showDate = input(defval=true, title='Show Date Range')timePeriod = time >= timestamp(syminfo.timezone, 2018, 1, 1, 0, 0)// Inputsts_bars = input.int(9, minval=1, title='Tenkan-Sen Bars')ks_bars = input.int(26, minval=1, title='Kijun-Sen Bars')ssb_bars = input.int(52, minval=1, title='Senkou-Span B Bars')cs_offset = input.int(26, minval=1, title='Chikou-Span Offset')ss_offset = input.int(26, minval=1, title='Senkou-Span Offset')long_entry = input(true, title='Long Entry')short_entry = input(true, title='Short Entry')middle(len) => math.avg(ta.lowest(len), ta.highest(len))// Ichimoku Componentstenkan = middle(ts_bars)kijun = middle(ks_bars)senkouA = math.avg(tenkan, kijun)senkouB = middle(ssb_bars)// Plot Ichimoku Kinko Hyoplot(tenkan, color=color.new(#0496ff, 0), title='Tenkan-Sen')plot(kijun, color=color.new(#991515, 0), title='Kijun-Sen')plot(close, offset=-cs_offset + 1, color=color.new(#459915, 0), title='Chikou-Span')sa = plot(senkouA, offset=ss_offset - 1, color=color.new(color.green, 0), title='Senkou-Span A')sb = plot(senkouB, offset=ss_offset - 1, color=color.new(color.red, 0), title='Senkou-Span B')fill(sa, sb, color=senkouA > senkouB ? color.green : color.red, title='Cloud color', transp=90)ss_high = math.max(senkouA[ss_offset - 1], senkouB[ss_offset - 1])ss_low = math.min(senkouA[ss_offset - 1], senkouB[ss_offset - 1])// ADX[pos_dm, neg_dm, avg_dm] = ta.dmi(14, 14)// Entry/Exit Signalstk_cross_bull = tenkan > kijuntk_cross_bear = tenkan < kijuncs_cross_bull = ta.mom(close, cs_offset - 1) > 0cs_cross_bear = ta.mom(close, cs_offset - 1) < 0price_above_kumo = close > ss_highprice_below_kumo = close < ss_lowbullish = tk_cross_bull and cs_cross_bull and price_above_kumo and avg_dm < 45 and pos_dm > neg_dmbearish = tk_cross_bear and cs_cross_bear and price_below_kumo and avg_dm > 45 and pos_dm < neg_dm// Configure trail stop level with input optionslongTrailPerc = input.float(title='Trail Long Loss (%)', minval=0.0, step=0.1, defval=3) * 0.01shortTrailPerc = input.float(title='Trail Short Loss (%)', minval=0.0, step=0.1, defval=3) * 0.01// Determine trail stop loss priceslongStopPrice = 0.0shortStopPrice = 0.0longStopPrice := if strategy.position_size > 0    stopValue = close * (1 - longTrailPerc)    math.max(stopValue, longStopPrice[1])else    0shortStopPrice := if strategy.position_size < 0    stopValue = close * (1 + shortTrailPerc)    math.min(stopValue, shortStopPrice[1])else    999999strategy.entry('Long', strategy.long, when=bullish and long_entry and timePeriod)strategy.exit('Long', stop = longStopPrice, limit = shortStopPrice)//strategy.entry('Short', strategy.short, when=bearish and short_entry and timePeriod)//strategy.exit('Short', stop = longStopPrice, limit = shortStopPrice)