Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

(IK) Stoch-60-15

A Pine Script v4 strategy built on Stoch (close, high) and SMA (sto, 2). It has 4 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss. Each trade commits 100.0 in cash and pays 0.1% commission. 8 settings; defaults include Stochastic Length 18, Stochastic %K 2 and Stochastic %D 10.

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 (IK) Stoch-60-15 repaint?
No
No repainting patterns were found in the source. The live replay was not measured: the script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script.
How did (IK) Stoch-60-15 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 (IK) Stoch-60-15 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 (IK) Stoch-60-15 use a stop loss?
Yes
strategy.exit sets a stop on line 38.
Does (IK) Stoch-60-15 run in Zeal Terminal?
Yes
It compiles in 41 ms and runs 1,000 bars in 73 ms, in the browser.

BTCUSDT · 1D · default settings

  • %K
  • %D
  • Upper Limit
  • Midline
  • Lower Limit
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct%K$100$203Equity from $100
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. Zeal Terminal's engine currently reads an order side written as long = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 32) so the engine trades the way the script says. The live re-run is not offered here: the script requests BINANCE:BTCUSDT 60, which this page cannot load in your browser.

Needs BINANCE:BTCUSDT 60 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Values that depend on it are empty on this chart.

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 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.

  • Note

    No slippage

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

  • Note

    Uses transp =, which v5 removed line 51

    transp = on line 51. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 32

    long = on line 32. 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 stoch → ta.stoch, sma → ta.sma, security → request.security, crossunder → ta.crossunder.

v4 → v5

Not verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 9: input(type = input.bool) → input.bool()
  • Line 10: input(type = input.float) → input.float()
  • Line 11: input(type = input.float) → input.float()
  • Line 12: input(type = input.float) → input.float()
  • Line 13: input(type = input.float) → input.float()
7 more edits
  • Line 19: stoch → ta.stoch
  • Line 20: sma → ta.sma
  • Line 21: sma → ta.sma
  • Line 25: security → request.security
  • Line 32: long = strategy.long → direction = strategy.long
  • Line 41: crossunder → ta.crossunder
  • Line 51: transp = 75 → color.new(color.purple, 75)
⋯// © userIan-//@version=4+//@version=5strategy(title="(IK) 60-15", precision=2, default_qty_type=strategy.cash, default_qty_value=100.0, initial_capital=100.0, currency="USD", commission_type=strategy.commission.percent, commission_value=0.1)⋯i_d             = input(group="Stochastic", title="Stochastic %D", minval=1, defval=10)-i_trailingStop  = input(group="Trade Settings", title="Trailing Stop?", type=input.bool, defval=true)                           // should stop loss be dynamic, based on most recent high, or static, based on entry price?+i_trailingStop  = input.bool(group="Trade Settings", title="Trailing Stop?", defval=true)                           // should stop loss be dynamic, based on most recent high, or static, based on entry price?-i_stopPercent   = input(group="Trade Settings", title="Stop Percent", type=input.float, defval=0.05, maxval=1.0, minval=0.001)  // how much (percentage) can price fall before exiting the trade+i_stopPercent   = input.float(group="Trade Settings", title="Stop Percent", defval=0.05, maxval=1.0, minval=0.001)  // how much (percentage) can price fall before exiting the trade-i_takeProfit    = input(group="Trade Settings", title="Take Profit", type=input.float, defval=0.05, maxval=1.0, minval=0.001)   // how much (percentage) can price rise before exiting the trade+i_takeProfit    = input.float(group="Trade Settings", title="Take Profit", defval=0.05, maxval=1.0, minval=0.001)   // how much (percentage) can price rise before exiting the trade-i_sellThreshold = input(group="Trade Settings", title="Sell Threshold", type=input.float, defval=75.0, maxval=100, minval=0.0)  // when stochastic %D crosses under this value, exit the trade+i_sellThreshold = input.float(group="Trade Settings", title="Sell Threshold", defval=75.0, maxval=100, minval=0.0)  // when stochastic %D crosses under this value, exit the trade-i_buyThreshold  = input(group="Trade Settings", title="Buy Threshold", type=input.float, defval=40.0, maxval=100, minval=0.0)   // stochastic %D must be below this value to enter a trade+i_buyThreshold  = input.float(group="Trade Settings", title="Buy Threshold", defval=40.0, maxval=100, minval=0.0)   // stochastic %D must be below this value to enter a trade// declare order variables⋯// build stochastic-sto = stoch(close, high, low, i_length)+sto = ta.stoch(close, high, low, i_length)-K   = sma(sto, i_k)+K   = ta.sma(sto, i_k)-D   = sma(K, i_d)+D   = ta.sma(K, i_d)// get stochastic trend⋯// get stochastic trend for 60 minute-stoch_60         = security(syminfo.tickerid, "60", D)+stoch_60         = request.security(syminfo.tickerid, "60", D)stoch_60_upTrend = (stoch_60[4] >= stoch_60[8])⋯    stop       := (close * (1-i_stopPercent)) -    strategy.entry(id="60-15-Long", long=strategy.long, comment='buy')+    strategy.entry(id="60-15-Long", direction = strategy.long, comment='buy')// update recent high, trailing stop⋯    strategy.close(id="60-15-Long", comment='sell-profit')-if crossunder(D, i_sellThreshold) and barstate.isconfirmed+if ta.crossunder(D, i_sellThreshold) and barstate.isconfirmed    strategy.close(id="60-15-Long", comment='sell-trend')⋯lowerBand  = hline(i_buyThreshold, title="Lower Limit", linestyle=hline.style_dashed)-fill(lowerBand, upperBand, color=color.purple, transp=75)+fill(lowerBand, upperBand, color=color.new(color.purple, 75))

Clean v5

Not verified

Neither 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 8: input() → input.int()
⋯// get input -i_length        = input(group="Stochastic", title="Stochastic Length", minval=1, defval=18)                                     +i_length        = input.int(group="Stochastic", title="Stochastic Length", minval=1, defval=18)                                     -i_k             = input(group="Stochastic", title="Stochastic %K", minval=1, defval=2)+i_k             = input.int(group="Stochastic", title="Stochastic %K", minval=1, defval=2)-i_d             = input(group="Stochastic", title="Stochastic %D", minval=1, defval=10)+i_d             = input.int(group="Stochastic", title="Stochastic %D", minval=1, defval=10)i_trailingStop  = input.bool(group="Trade Settings", title="Trailing Stop?", defval=true)                           // should stop loss be dynamic, based on most recent high, or static, based on entry price?⋯

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.

⋯// © userIan-//@version=5+//@version=6strategy(title="(IK) 60-15", precision=2, default_qty_type=strategy.cash, default_qty_value=100.0, initial_capital=100.0, currency="USD", commission_type=strategy.commission.percent, commission_value=0.1)⋯

Settings

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

SettingDefaultType and rangeFeeds
Stochastic
Stochastic Length18int · min 1sto
Stochastic %K2int · min 1K
Stochastic %D10int · min 1D
Trade Settings
Trailing Stop?trueboolstop
Stop Percent0.05float · min 0.001 · max 1.0stop
Take Profit0.05float · min 0.001 · max 1.0close 60-15-Long line 39
Sell Threshold75.0float · min 0.0 · max 100Upper Limit close 60-15-Long line 41
Buy Threshold40.0float · min 0.0 · max 100Lower Limit entry 60-15-Long line 28

What it calculates

  • Stoch (stoch, ta.stoch in v5)close, high, low, Stochastic Length (18)sto · line 19
  • SMA (sma, ta.sma in v5)sto, Stochastic %K (2)K · line 20
  • SMA (sma, ta.sma in v5)K, Stochastic %D (10)D · line 21

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.

lowlowprice datahighhighprice dataclosecloseprice datai_lengthStochastic Lengthsetting · 18i_kStochastic %Ksetting · 2i_dStochastic %Dsetting · 10i_stopPercentStop Percentsetting · 0.05i_buyThresholdBuy Thresholdsetting · 40.0i_takeProfitTake Profitsetting · 0.05i_sellThresholdSell Thresholdsetting · 75.0stoStoch→ stoKSMA→ KDSMA→ DrecentHigh, entryPricerecentHigh · entryPrice2 valuesstopstopvaluestoch_60stoch_60valuestoch_upTrendstoch_upTrendconditionstoch_60_upTrendstoch_60_upTrendconditionentry:60-15-LongOpen 60-15-Longstrategy.entryexit:60-15-Longexit 60-15-Longstrategy.exitclose:60-15-LongClose 60-15-Longstrategy.closeplot:45%Kplotplot:46%Dplotplot:47Hourly Stochastic (D)plothline:48Upper Limithlinehline:49Midlinehlinehline:50Lower Limithlinefill:51Fillfill

Order rules

OrderFires whenBy defaultLine
Open 60-15-Long long(D < i_buyThreshold) and stoch_upTrend and stoch_60_upTrend and barstate.isconfirmedOn32
Exit 60-15-Long stopevery barOn38
Close 60-15-Longclose > (entryPrice * (1+i_takeProfit)) and barstate.isconfirmedOn40
Close 60-15-Longcrossunder(D, i_sellThreshold) and barstate.isconfirmedOn42

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 measuredAn engine gap, not the scriptThe script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script. The answer comes from the checks on the source alone.
  • ClearHigher-timeframe data1 security call(s), none with lookahead on.
  • 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

Not run on other markets: the script requests BINANCE:BTCUSDT 60, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data). Its results would rest on empty values.

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
(IK) Stoch-60-15 this page—v4 strategy0.0%00.0%
Stochastic Oscillator by Zeal Terminalstoch smav5 indicatorindicator
CCI Level Zone by Naruephatsma stochv5 strategyNo trades on this market
Stochastic Moving Average by LucasVivienstoch smav5 strategy+2.8%74.4%
OTT-Stoch-TP-SL by BigCoinHuntersma stochv5 strategyNo trades on this market
AVWAP Strategy by asfbherostoch smav5 strategydoes not run in Zeal Terminal

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 41 msWith a workaround 1,000 bars in 73 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 32) 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/// © userIan//@version=4strategy(title="(IK) 60-15", precision=2, default_qty_type=strategy.cash, default_qty_value=100.0, initial_capital=100.0, currency="USD", commission_type=strategy.commission.percent, commission_value=0.1)// get input i_length        = input(group="Stochastic", title="Stochastic Length", minval=1, defval=18)                                     i_k             = input(group="Stochastic", title="Stochastic %K", minval=1, defval=2)i_d             = input(group="Stochastic", title="Stochastic %D", minval=1, defval=10)i_trailingStop  = input(group="Trade Settings", title="Trailing Stop?", type=input.bool, defval=true)                           // should stop loss be dynamic, based on most recent high, or static, based on entry price?i_stopPercent   = input(group="Trade Settings", title="Stop Percent", type=input.float, defval=0.05, maxval=1.0, minval=0.001)  // how much (percentage) can price fall before exiting the tradei_takeProfit    = input(group="Trade Settings", title="Take Profit", type=input.float, defval=0.05, maxval=1.0, minval=0.001)   // how much (percentage) can price rise before exiting the tradei_sellThreshold = input(group="Trade Settings", title="Sell Threshold", type=input.float, defval=75.0, maxval=100, minval=0.0)  // when stochastic %D crosses under this value, exit the tradei_buyThreshold  = input(group="Trade Settings", title="Buy Threshold", type=input.float, defval=40.0, maxval=100, minval=0.0)   // stochastic %D must be below this value to enter a trade// declare order variablesvar recentHigh  = 0.0   // the highest high while in a tradevar stop        = 0.0   // the price that will trigger as stop lossvar entryPrice  = 0.0   // the price when the trade was entered// build stochasticsto = stoch(close, high, low, i_length)K   = sma(sto, i_k)D   = sma(K, i_d)// get stochastic trendstoch_upTrend = D > D[1]// get stochastic trend for 60 minutestoch_60         = security(syminfo.tickerid, "60", D)stoch_60_upTrend = (stoch_60[4] >= stoch_60[8])// entryif (D < i_buyThreshold) and stoch_upTrend and stoch_60_upTrend and barstate.isconfirmed    recentHigh := close    entryPrice := close    stop       := (close * (1-i_stopPercent))     strategy.entry(id="60-15-Long", long=strategy.long, comment='buy')// update recent high, trailing stopif close > recentHigh      recentHigh := close    stop       := i_trailingStop ? (recentHigh * (1-i_stopPercent)) : stop// exitstrategy.exit(id="60-15-Long", stop=stop, comment='sell-stop')if close > (entryPrice * (1+i_takeProfit)) and barstate.isconfirmed    strategy.close(id="60-15-Long", comment='sell-profit')if crossunder(D, i_sellThreshold) and barstate.isconfirmed    strategy.close(id="60-15-Long", comment='sell-trend')    // plotplot(K, title="%K", color=color.blue, linewidth=1)plot(D, title="%D", color=color.orange, linewidth=1)plot(stoch_60, title="Hourly Stochastic (D)", color= stoch_60_upTrend ? color.green : color.red, style=plot.style_stepline)upperBand  = hline(i_sellThreshold, title="Upper Limit", linestyle=hline.style_dashed)middleBand = hline(50, title="Midline", linestyle=hline.style_dotted)lowerBand  = hline(i_buyThreshold, title="Lower Limit", linestyle=hline.style_dashed)fill(lowerBand, upperBand, color=color.purple, transp=75)