Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

KDJ Strategy @ionvolution

A Pine Script v5 strategy built on SMA (close, 200), Highest (high, 14) and Lowest (low, 14). It has 3 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 is one contract and pays no commission. 11 settings; defaults include Period 14, Signal 8 and SMA 200.

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 KDJ Strategy @ionvolution repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did KDJ Strategy @ionvolution 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 code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does KDJ Strategy @ionvolution run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L60:C40: 'bgcolor' 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 KDJ Strategy @ionvolution use a stop loss?
Yes
strategy.exit sets a stop on line 50.
Does KDJ Strategy @ionvolution run in Zeal Terminal?
Yes
It compiles in 19 ms and runs 1,000 bars in 43 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • 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 (11)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000,000$2,025,273Equity from $1,000,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. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
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, $1,000,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 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 53. 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
Period14inth l
Signal8intpK pD
SMA200intma
Profit Margin1.20float · min 1.0 · max 1.99 · step 0.01exit S
Stop Loss Margin0.98float · min 0.0 · max 1 · step 0.01exit S
Start Date1int · min 1 · max 31inDateRange
Start Month1int · min 1 · max 12inDateRange
Start Year2022int · min 2018 · max 2023inDateRange
End Date1int · min 1 · max 31inDateRange
End Month1int · min 1 · max 12inDateRange
End Year2022int · min 2018 · max 2099inDateRange

What it calculates

  • SMAclose, SMA (200)ma · line 39
  • Highesthigh, Period (14)h · line 40
  • Lowestlow, Period (14)l · line 41

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 dataismaSMAsetting · 200highhighprice datailongPeriodsetting · 14lowlowprice dataisigSignalsetting · 8timetimeprice datastartYearStart Yearsetting · 2022startMonthStart Monthsetting · 1startDateStart Datesetting · 1endYearEnd Yearsetting · 2022endMonthEnd Monthsetting · 1endDateEnd Datesetting · 1maSMA→ mahHighest→ hlLowest→ l_bcwsma_bcwsmavalue_s, _m_s · _m2 values_l_lvalueccvalueRSVRSVvaluepKpKvaluepDpDvaluepJpJvalueinDateRangeinDateRangeconditiongo_longgo_longconditiongo_shortgo_shortconditionentry:SOpen Sstrategy.entryexit:Sexit Sstrategy.exitclose:SClose Sstrategy.closeplot:58plotplotbgcolor:59bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Open S long(inDateRange and go_long)On49
Exit S stop and limit(inDateRange and go_long)On50
Close Sgo_shortta.crossover(pD,pJ) or close < maOn53

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 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—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.

ScriptSharesTypeNetTradesMax drawdown
KDJ Strategy @ionvolution this page—v5 strategy0.0%00.0%
ChBrkOutStrategySMA by anshuanshu333sma highest lowestv4 strategy−4.5%4220.9%
Trading range display with Box by potatoshopsma highest lowestv5 strategy+0.7%273.9%
Open Drive by Marcns_highest lowest smav5 strategyNo trades on this market
Trend Bounce [racer8] by racer8highest lowest smav4 strategy+2.4%2232.2%
Lawyers Trend Pro Strategy by ErdemDemirsma lowest highestv4 strategy+12.1%10241.7%

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 53). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 53: when = go_short → if block
⋯if (inDateRange and go_short)-    strategy.close("S",when=go_short,comment="V")+    if go_short+        strategy.close("S",comment="V")    ⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L60:C40: 'bgcolor' 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.

⋯// © ionvolution-// @version = 5+// @version = 6//strategy("KDJ IAM Strategy",shorttitle="kdj @ionvolution",overlay=true,default_qty_value=1,initial_capital=100,currency=currency.EUR)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 19 msWith a workaround 1,000 bars in 43 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“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/// Buys if there is crossover in J and D and the crossover is above an SMA defined as an input parameter// Sells if the close is below the SMA or there is a crossunder in J and D// The KDJ calculation is done using ll21LAMBOS21 script. I added start date, end date, stop loss margin and stop profit margin to // ease the simulation on diferent conditions of the market.// Tested on BTCBUSD pair. Gives good results in 30m candles with K period = 7 and D period = 3, but also works fine with K period = 14 and D period = 8// It works fine when market is bullish and gives false signals in flat markets.// I just developed long strategy, as it is developed to work in SPOT trading.// © ionvolution// @version = 5//strategy("KDJ IAM Strategy",shorttitle="kdj @ionvolution",overlay=true,default_qty_value=1,initial_capital=100,currency=currency.EUR)strategy("KDJ IAM Strategy",shorttitle="kdj @ionvolution",overlay=true)// Input parameters ilong = input.int(14,"Period")isig = input.int(8, "Signal")isma = input.int(200, "SMA")// Function to compute average for KDJbcwsma(s, l, m) =>    _bcwsma = float(na)    _s = s    _l = l    _m = m    _bcwsma := (_m * _s + (_l - _m) * nz(_bcwsma[1])) / _l    _bcwsmaprofit_m = input.float(1.20,"Profit Margin",minval=1.0,maxval=1.99,step=0.01)stop_m = input.float(0.98,"Stop Loss Margin",minval=0.0,maxval=1,step=0.01)// Make input options that configure backtest date rangestartDate = input.int(title="Start Date", defval=1, minval=1,maxval=31)startMonth = input.int(title="Start Month", defval=1,minval=1,maxval=12)startYear = input.int(title="Start Year", defval=2022,minval=2018,maxval=2023)endDate = input.int(title="End Date", defval=1, minval=1,maxval=31)endMonth = input.int(title="End Month", defval=1,minval=1,maxval=12)endYear = input.int(title="End Year", defval=2022,minval=2018,maxval=2099)// intialization of variables// Look if the close time of the current bar// falls inside the date rangeinDateRange = (time >= timestamp(syminfo.timezone, startYear,startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))c = closema = ta.sma(close,isma)h = ta.highest(high, ilong)l = ta.lowest(low,ilong)RSV = 100*((c-l)/(h-l))pK = bcwsma(RSV, isig, 1)pD = bcwsma(pK, isig, 1)pJ = 3 * pK-2 * pDgo_long= ta.crossover(pJ,pD) and close >mago_short= ta.crossover(pD,pJ) or close < maif (inDateRange and go_long)    strategy.entry("S",strategy.long,comment="C")    strategy.exit("S", limit=c*profit_m, stop=c*stop_m, comment="SL/SP")    if (inDateRange and go_short)    strategy.close("S",when=go_short,comment="V")    // Plot options//plot(pK, color= #1E88E5,transp=0)//plot(pD, color=#FF6F00,transp=0)plot(ma, color=color.yellow)bgcolor(pJ>pD? color.green : color.red, transp=75)//h0 = hline(80)//h1 = hline(20)