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
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 verifiedNeither 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 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 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Stochastic | |||
| Stochastic Length | 18 | int · min 1 | sto |
| Stochastic %K | 2 | int · min 1 | K |
| Stochastic %D | 10 | int · min 1 | D |
| Trade Settings | |||
| Trailing Stop? | true | bool | stop |
| Stop Percent | 0.05 | float · min 0.001 · max 1.0 | stop |
| Take Profit | 0.05 | float · min 0.001 · max 1.0 | close 60-15-Long line 39 |
| Sell Threshold | 75.0 | float · min 0.0 · max 100 | Upper Limit close 60-15-Long line 41 |
| Buy Threshold | 40.0 | float · min 0.0 · max 100 | Lower Limit entry 60-15-Long line 28 |
What it calculates
- Stoch (
stoch,ta.stochin v5)close, high, low, Stochastic Length (18)sto · line 19 - SMA (
sma,ta.smain v5)sto, Stochastic %K (2)K · line 20 - SMA (
sma,ta.smain 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open 60-15-Long long | (D < i_buyThreshold) and stoch_upTrend and stoch_60_upTrend and barstate.isconfirmed | On | 32 |
| Exit 60-15-Long stop | every bar | On | 38 |
| Close 60-15-Long | close > (entryPrice * (1+i_takeProfit)) and barstate.isconfirmed | On | 40 |
| Close 60-15-Long | crossunder(D, i_sellThreshold) and barstate.isconfirmed | On | 42 |
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 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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| (IK) Stoch-60-15 this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| Stochastic Oscillator by Zeal Terminal | stoch sma | v5 indicator | indicator | ||
| CCI Level Zone by Naruephat | sma stoch | v5 strategy | No trades on this market | ||
| Stochastic Moving Average by LucasVivien | stoch sma | v5 strategy | +2.8% | 7 | 4.4% |
| OTT-Stoch-TP-SL by BigCoinHunter | sma stoch | v5 strategy | No trades on this market | ||
| AVWAP Strategy by asfbhero | stoch sma | v5 strategy | does not run in Zeal Terminal | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 41 ms | With a workaround 1,000 bars in 73 ms | Not measured |
| PineTS | No 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)