Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

KSR Strategy

A Pine Script v4 strategy built on EMA (close, 10), Crossover (ema1, ema2) and Crossunder (ema1, ema2). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 7 settings; defaults include Par1 10, Par2 20 and MA1 8.

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 KSR Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 11 of 11 trades.
How did KSR Strategy do on BTCUSDT 1D with default settings?
+35.33%
From 26 Jan 2024 to 21 Oct 2026, over 42 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can KSR Strategy be converted to Pine Script v5?
No
The automatic step from v4 to v5 gives a script that does not run in v5 (Pine Script v5 Error at @L24:C15: 'label.style_labelup' is not available in Pine Script v5. It was added in a later version), so no v5 download is offered; the edits are shown below.
Does KSR Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does KSR Strategy run in Zeal Terminal?
Yes
It compiles in 26 ms and runs 1,000 bars in 104 ms, in the browser.

BTCUSDT · 1D · default settings

  • Up Arrow
  • Down Arrow
  • EMA Short
  • EMA Long
  • EMA
  • Shape
  • Shape
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
63924.5165235.2166043.9965043.9960697.9964037.2459359.0160313.9960636.0263206.2294881.4798663.5895791.6102235.692552.4999987.397763.1387232.0184424.3884947.91104288.44105552.15104886.78106947.06112546.35116462.25112872.94116029.42108994.49118594.9911516690628.0189559.6770541.3466407.2871069.9376834.3664161.7262823.6464923.1963479.9969334.7981682.018470440,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$132,306$202,527Equity from $100,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. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep. 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. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView. The live re-run is not offered here: the script requests heikinashi:SYMBOL W, heikinashi:SYMBOL D, heikinashi:BINANCE:BTCUSDT W, heikinashi:BINANCE:BTCUSDT D, which this page cannot load in your browser.
Net profit
+35.33%
$35,330.80
Buy and hold
+102.5%
same period
Closed trades
42
12 won · 30 lost
Profitable
28.6%
of closed trades
Profit factor
1.33
gross profit ÷ gross loss
Max drawdown
41.32%
−$48,181.80

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A short position was still open at the last bar. 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.

  • Likely bug

    ema(close, 100) ignores the settings line 13

    Line 13 hard-codes 100 where line 7 uses “Par1”. Changing those settings moves one band but not this one.

    ema(close,100)ema(close, par1)
  • 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

    2 settings have no label

    In the settings dialog par1 (line 5), par2 (line 6) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

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

  • Note

    Uses iff(), which v5 removed line 11

    iff() on line 11, 11. v5 writes it as the ternary c ? a : b.

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 ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder, tostring → str.tostring, heikinashi → ticker.heikinashi, security → request.security.

v4 → v5

Differs

The v5 version does not run in Zeal Terminal's engine: Pine Script v5 Error at @L24:C15: 'label.style_labelup' is not available in Pine Script v5. It was added in a later version.

  • Line 3: //@version=4 → //@version=5
  • Line 7: ema → ta.ema
  • Line 8: ema → ta.ema
  • Line 11: iff(c, a, b) → (c ? a : b)
  • Line 11: iff(c, a, b) → (c ? a : b)
  • Line 13: ema → ta.ema
45 more edits
  • Line 14: crossover → ta.crossover
  • Line 15: crossunder → ta.crossunder
  • Line 16: tostring → str.tostring
  • Line 19: crossover → ta.crossover
  • Line 19: ema → ta.ema
  • Line 19: ema → ta.ema
  • Line 21: tostring → str.tostring
  • Line 26: crossunder → ta.crossunder
  • Line 26: ema → ta.ema
  • Line 26: ema → ta.ema
  • Line 28: tostring → str.tostring
  • Line 33: ema → ta.ema
  • Line 34: ema → ta.ema
  • Line 35: crossover → ta.crossover
  • Line 35: ema → ta.ema
  • Line 35: ema → ta.ema
  • Line 38: crossunder → ta.crossunder
  • Line 38: ema → ta.ema
  • Line 38: ema → ta.ema
  • Line 41: input(type = input.integer) → input.int()
  • Line 42: input(type = input.integer) → input.int()
  • Line 43: ema → ta.ema
  • Line 44: ema → ta.ema
  • Line 45: ema → ta.ema
  • Line 46: ema → ta.ema
  • Line 49: input(type = input.integer) → input.int()
  • Line 50: ema → ta.ema
  • Line 52: heikinashi → ticker.heikinashi
  • Line 53: security → request.security
  • Line 54: security → request.security
  • Line 55: security → request.security
  • Line 56: security → request.security
  • Line 57: ema → ta.ema
  • Line 58: ema → ta.ema
  • Line 59: ema → ta.ema
  • Line 60: ema → ta.ema
  • Line 63: heikinashi → ticker.heikinashi
  • Line 64: security → request.security
  • Line 65: security → request.security
  • Line 66: security → request.security
  • Line 67: security → request.security
  • Line 68: ema → ta.ema
  • Line 69: ema → ta.ema
  • Line 70: ema → ta.ema
  • Line 71: ema → ta.ema
⋯// © askkuldeeprandhawa-//@version=4+//@version=5strategy("KSR Strategy", overlay=true)⋯par2=input(20)-ema1=ema(close,par1)+ema1=ta.ema(close,par1)-ema2=ema(close,par2)+ema2=ta.ema(close,par2)buy=ema1>ema2sell=ema2<ema1-mycolor= iff(buy,color.green,iff(sell,color.blue,color.red))+mycolor= (buy ? color.green : (sell ? color.blue : color.red))barcolor(color=mycolor)-ema100=ema(close,100)+ema100=ta.ema(close,100)-ibuy=crossover(ema1,ema2)+ibuy=ta.crossover(ema1,ema2)-iSell=crossunder(ema1,ema2)+iSell=ta.crossunder(ema1,ema2)-varp=tostring(close[1])+varp=str.tostring(close[1])plotshape(ibuy, "Up Arrow", shape.triangleup, location.belowbar, color.green, 0, 0,"Buy" , color.green, true, size.tiny)plotshape(iSell, "Down Arrow", shape.triangledown, location.abovebar, color.red, 0, 0, "Sell", color.red, true, size.tiny)-crossed =crossover(ema(close,par1), ema(close,par2))+crossed =ta.crossover(ta.ema(close,par1), ta.ema(close,par2))if crossed-    l = label.new(bar_index, na, tostring(close), +    l = label.new(bar_index, na, str.tostring(close),          color=color.green, ⋯         -crossed2 =crossunder(ema(close,par1), ema(close,par2))+crossed2 =ta.crossunder(ta.ema(close,par1), ta.ema(close,par2))if crossed2-    l = label.new(bar_index, na, tostring(close), +    l = label.new(bar_index, na, str.tostring(close),          color=color.red, ⋯         -plot(ema(close,par1),"EMA Short",color=color.white)+plot(ta.ema(close,par1),"EMA Short",color=color.white)-plot(ema(close,par2),"EMA Long",color=color.orange)+plot(ta.ema(close,par2),"EMA Long",color=color.orange)-longCondition = crossover(ema(close, par1), ema(close, par2))+longCondition = ta.crossover(ta.ema(close, par1), ta.ema(close, par2))if (longCondition)    strategy.entry("My Long Entry Id", strategy.long)-shortCondition = crossunder(ema(close, par1), ema(close, par2))+shortCondition = ta.crossunder(ta.ema(close, par1), ta.ema(close, par2))if (shortCondition)    strategy.entry("My Short Entry Id", strategy.short)-ma1_len = input(title="MA1", type=input.integer, defval=8, minval=1, maxval=100, step=1)+ma1_len = input.int(title="MA1", defval=8, minval=1, maxval=100, step=1)-ma2_len = input(title="MA2", type=input.integer, defval=12, minval=1, maxval=100, step=1)+ma2_len = input.int(title="MA2", defval=12, minval=1, maxval=100, step=1)-o = ema(open, ma1_len)+o = ta.ema(open, ma1_len)-c = ema(close, ma1_len)+c = ta.ema(close, ma1_len)-h = ema(high, ma1_len)+h = ta.ema(high, ma1_len)-l = ema(low, ma1_len)+l = ta.ema(low, ma1_len)tim1=input('D',"Short Time")tim2=input('W',"Long Time")-ema_p=input(title="EMA Period", type=input.integer, defval=16, minval=1, maxval=100, step=1)+ema_p=input.int(title="EMA Period", defval=16, minval=1, maxval=100, step=1)-refma = ema(close, ema_p)+refma = ta.ema(close, ema_p)plot(refma, title="EMA" , linewidth=1, color=close < refma ? color.orange : color.blue)-ha_t = heikinashi(syminfo.tickerid)+ha_t = ticker.heikinashi(syminfo.tickerid)-ha_o = security(ha_t, tim2, o)+ha_o = request.security(ha_t, tim2, o)-ha_c = security(ha_t, tim2, c)+ha_c = request.security(ha_t, tim2, c)-ha_h = security(ha_t, tim2, h)+ha_h = request.security(ha_t, tim2, h)-ha_l = security(ha_t, tim2, l)+ha_l = request.security(ha_t, tim2, l)-o2 = ema(ha_o, ma2_len)+o2 = ta.ema(ha_o, ma2_len)-c2 = ema(ha_c, ma2_len)+c2 = ta.ema(ha_c, ma2_len)-h2 = ema(ha_h, ma2_len)+h2 = ta.ema(ha_h, ma2_len)-l2 = ema(ha_l, ma2_len)+l2 = ta.ema(ha_l, ma2_len)ha_col = ha_c > ha_o ? color.red : color.greenplotshape(true, style=shape.circle, color=ha_c > ha_o ? color.green : color.red, location=location.bottom)-ha_t1 = heikinashi(syminfo.tickerid)+ha_t1 = ticker.heikinashi(syminfo.tickerid)-ha_o1 = security(ha_t1, tim1, o)+ha_o1 = request.security(ha_t1, tim1, o)-ha_c1 = security(ha_t1, tim1, c)+ha_c1 = request.security(ha_t1, tim1, c)-ha_h1 = security(ha_t1, tim1, h)+ha_h1 = request.security(ha_t1, tim1, h)-ha_l1 = security(ha_t1, tim1, l)+ha_l1 = request.security(ha_t1, tim1, l)-o3 = ema(ha_o1, ma2_len)+o3 = ta.ema(ha_o1, ma2_len)-c3 = ema(ha_c1, ma2_len)+c3 = ta.ema(ha_c1, ma2_len)-h3 = ema(ha_h1, ma2_len)+h3 = ta.ema(ha_h1, ma2_len)-l3 = ema(ha_l1, ma2_len)+l3 = ta.ema(ha_l1, ma2_len)ha_col1 = ha_c1 > ha_o1 ? color.red : color.green⋯

Clean v5

Not verified

The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L24:C15: 'label.style_labelup' is not available in Pine Script v5. It was added in a later version.), so this step could not be checked.

  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
  • Line 47: input() → input.string()
  • Line 48: input() → input.string()
⋯strategy("KSR Strategy", overlay=true)-par1=input(10)+par1=input.int(10)-par2=input(20)+par2=input.int(20)ema1=ta.ema(close,par1)⋯l = ta.ema(low, ma1_len)-tim1=input('D',"Short Time")+tim1=input.string('D',"Short Time")-tim2=input('W',"Long Time")+tim2=input.string('W',"Long Time")ema_p=input.int(title="EMA Period", defval=16, minval=1, maxval=100, step=1)⋯

Does it run in Pine Script v6?

Not tested

The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L24:C15: 'label.style_labelup' is not available in Pine Script v5. It was added in a later version.), so this step could not be checked. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © askkuldeeprandhawa-//@version=5+//@version=6strategy("KSR Strategy", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Par1 (no label in the script)10intema1 crossed crossed2 longCondition shortCondition EMA Short
Par2 (no label in the script)20intema2 crossed crossed2 longCondition shortCondition EMA Long
MA18int (written input.integer) · min 1 · max 100 · step 1l o c h
MA212int (written input.integer) · min 1 · max 100 · step 1o2 c2 h2 l2 o3 c3 h3 l3
Short TimeDstringha_o1 ha_c1 ha_h1 ha_l1
Long TimeWstringha_o ha_c ha_h ha_l
EMA Period16int (written input.integer) · min 1 · max 100 · step 1refma

What it calculates

  • EMA (ema, ta.ema in v5)close, Par1 (10)ema1 · line 7
  • EMA (ema, ta.ema in v5)close, Par2 (20)ema2 · line 8
  • EMA (ema, ta.ema in v5)close, 100ema100 · line 13
  • Crossover (crossover, ta.crossover in v5)ema1, ema2ibuy · line 14
  • Crossunder (crossunder, ta.crossunder in v5)ema1, ema2iSell · line 15
  • Crossover / EMA (crossover, ta.crossover in v5)ema(close,par1), ema(close,par2)crossed · line 19
  • EMA (ema, ta.ema in v5)low, MA1 (8)l · line 46
  • Crossunder / EMA (crossunder, ta.crossunder in v5)ema(close,par1), ema(close,par2)crossed2 · line 26
  • Crossover / EMA (crossover, ta.crossover in v5)ema(close, par1), ema(close, par2)longCondition · line 35
  • Crossunder / EMA (crossunder, ta.crossunder in v5)ema(close, par1), ema(close, par2)shortCondition · line 38
  • EMA (ema, ta.ema in v5)open, MA1 (8)o · line 43
  • EMA (ema, ta.ema in v5)close, MA1 (8)c · line 44
  • EMA (ema, ta.ema in v5)high, MA1 (8)h · line 45
  • EMA (ema, ta.ema in v5)close, EMA Period (16)refma · line 50
  • EMA (ema, ta.ema in v5)ha_o, MA2 (12)o2 · line 57
  • EMA (ema, ta.ema in v5)ha_c, MA2 (12)c2 · line 58
  • EMA (ema, ta.ema in v5)ha_h, MA2 (12)h2 · line 59
  • EMA (ema, ta.ema in v5)ha_l, MA2 (12)l2 · line 60
  • EMA (ema, ta.ema in v5)ha_o1, MA2 (12)o3 · line 68
  • EMA (ema, ta.ema in v5)ha_c1, MA2 (12)c3 · line 69
  • EMA (ema, ta.ema in v5)ha_h1, MA2 (12)h3 · line 70
  • EMA (ema, ta.ema in v5)ha_l1, MA2 (12)l3 · line 71

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 datapar1Par1setting · 10par2Par2setting · 20lowlowprice datama1_lenMA1setting · 8openopenprice datahighhighprice dataema_pEMA Periodsetting · 16ma2_lenMA2setting · 12tim2Long Timesetting · Wtim1Short Timesetting · Dema1EMA→ ema1ema2EMA→ ema2ema100EMA→ ema100ibuyCrossover→ ibuyiSellCrossunder→ iSellcrossedCrossover / EMA→ crossedlEMA→ lcrossed2Crossunder / EMA→ crossed2longConditionCrossover / EMA→ longConditionshortConditionCrossunder / EMA→ shortConditionoEMA→ ocEMA→ chEMA→ hrefmaEMA→ refmao2EMA→ o2c2EMA→ c2h2EMA→ h2l2EMA→ l2o3EMA→ o3c3EMA→ c3h3EMA→ h3l3EMA→ l3varpvarpvalueha_t, ha_t1ha_t · ha_t12 valuesha_oha_ovalueha_cha_cvalueha_hha_hvalueha_lha_lvalueha_o1ha_o1valueha_c1ha_c1valueha_h1ha_h1valueha_l1ha_l1valuebuy, sellbuy · sell2 conditionsmycolor, ha_col, ha_col1Colourmycolor · ha_col +1entry:My Long Entry IdOpen My Long Entry Idstrategy.entryentry:My Short Entry IdOpen My Short Entry Idstrategy.entrybarcolor:12barcolorbarcolorplotshape:17plotshapeplotshapeplotshape:18plotshapeplotshapeplot:33EMA Shortplotplot:34EMA Longplotplot:51EMAplotplotshape:62plotshapeplotshapeplotshape:73plotshapeplotshape

Order rules

OrderFires whenBy defaultLine
Open My Long Entry Id long(longCondition)On37
Open My Short Entry Id short(shortCondition)On40

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.

11/11trades 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 data8 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

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+35.3%+102.5%4229%1.3341.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−7.6%+5.5%5127%0.8414.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.5%+9.8%3631%1.242.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.6%+8.4%5721%0.741.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%3642%1.150.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%3727%1.980.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.4%+148.3%4028%1.470.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%4931%1.050.1%8 May 2026 – 21 Oct 2026

Higher-timeframe data for request.security(): heikinashi:SYMBOL W (Binance BTCUSDT 1w, as Heikin-Ashi by the engine), heikinashi:SYMBOL D (Binance BTCUSDT 1d, as Heikin-Ashi by the engine), heikinashi:BINANCE:BTCUSDT W (Binance BTCUSDT 1w, as Heikin-Ashi by the engine), heikinashi:BINANCE:BTCUSDT D (Binance BTCUSDT 1d, as Heikin-Ashi by the engine), fetched from Binance's public market data for each market.

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1625%−$15,633.60
Sideways market1729%$26,103.70
Falling market933%$24,860.70

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

How bad could the drawdown be?

46.7%

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

0%54%
All 42 trades
SideEntryExitBarsP&L
short14 Apr 2024 63,924.5017 May 2024 65,235.2033−$1,310.69
long17 May 2024 65,235.2015 Jun 2024 66,044.0029$808.78
short15 Jun 2024 66,044.0017 Jul 2024 65,044.0032$999.99
long17 Jul 2024 65,044.004 Aug 2024 60,698.0018−$4,346.01
short4 Aug 2024 60,698.0024 Aug 2024 64,037.2020−$3,339.25
long24 Aug 2024 64,037.2030 Aug 2024 59,359.006−$4,678.24
short30 Aug 2024 59,359.0018 Sep 2024 60,314.0019−$954.99
long18 Sep 2024 60,314.0010 Oct 2024 60,636.0022$322.02
short10 Oct 2024 60,636.0013 Oct 2024 63,206.203−$2,570.22
long13 Oct 2024 63,206.2024 Dec 2024 94,881.5072$31,675.20
short24 Dec 2024 94,881.5025 Dec 2024 98,663.601−$3,782.11
long25 Dec 2024 98,663.6027 Dec 2024 95,791.602−$2,871.98
short27 Dec 2024 95,791.607 Jan 2025 102,236.0011−$6,444.00
long7 Jan 2025 102,236.0010 Jan 2025 92,552.503−$9,683.11
short10 Jan 2025 92,552.5017 Jan 2025 99,987.307−$7,434.81
long17 Jan 2025 99,987.305 Feb 2025 97,763.1019−$2,224.16
short5 Feb 2025 97,763.1028 Mar 2025 87,232.0051$10,531.10
long28 Mar 2025 87,232.0029 Mar 2025 84,424.401−$2,807.63
short29 Mar 2025 84,424.4018 Apr 2025 84,947.9020−$523.54
long18 Apr 2025 84,947.907 Jun 2025 104,288.0050$19,340.50
short7 Jun 2025 104,288.008 Jun 2025 105,552.001−$1,263.72
long8 Jun 2025 105,552.0019 Jun 2025 104,887.0011−$665.36
short19 Jun 2025 104,887.0027 Jun 2025 106,947.008−$2,060.27
long27 Jun 2025 106,947.003 Aug 2025 112,546.0037$5,599.29
short3 Aug 2025 112,546.0010 Aug 2025 116,462.007−$3,915.90
long10 Aug 2025 116,462.0020 Aug 2025 112,873.0010−$3,589.30
short20 Aug 2025 112,873.0013 Sep 2025 116,029.0024−$3,156.46
long13 Sep 2025 116,029.0026 Sep 2025 108,994.0013−$7,034.92
short26 Sep 2025 108,994.002 Oct 2025 118,595.006−$9,600.50
long2 Oct 2025 118,595.0014 Oct 2025 115,166.0012−$3,428.99
short14 Oct 2025 115,166.004 Jan 2026 90,628.0082$24,538.00
long4 Jan 2026 90,628.0023 Jan 2026 89,559.7019−$1,068.33
short23 Jan 2026 89,559.7013 Mar 2026 70,541.3049$19,018.30
long13 Mar 2026 70,541.3028 Mar 2026 66,407.3015−$4,134.06
short28 Mar 2026 66,407.309 Apr 2026 71,069.9012−$4,662.65
long9 Apr 2026 71,069.9020 May 2026 76,834.4041$5,764.43
short20 May 2026 76,834.4011 Jul 2026 64,161.7052$12,672.60
long11 Jul 2026 64,161.702 Aug 2026 62,823.7022−$1,338.07
short2 Aug 2026 62,823.708 Aug 2026 64,923.206−$2,099.55
long8 Aug 2026 64,923.2013 Aug 2026 63,480.005−$1,443.21
short13 Aug 2026 63,480.0020 Aug 2026 69,334.807−$5,854.79
long20 Aug 2026 69,334.8015 Oct 2026 81,682.0056$12,347.20

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
KSR Strategy this page—v4 strategy+35.3%4241.3%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 26 msWith a workaround 1,000 bars in 104 msNot measured
PineTSNo v5 and v6 only—Not 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. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView.

“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/// © askkuldeeprandhawa//@version=4strategy("KSR Strategy", overlay=true)par1=input(10)par2=input(20)ema1=ema(close,par1)ema2=ema(close,par2)buy=ema1>ema2sell=ema2<ema1mycolor= iff(buy,color.green,iff(sell,color.blue,color.red))barcolor(color=mycolor)ema100=ema(close,100)ibuy=crossover(ema1,ema2)iSell=crossunder(ema1,ema2)varp=tostring(close[1])plotshape(ibuy, "Up Arrow", shape.triangleup, location.belowbar, color.green, 0, 0,"Buy" , color.green, true, size.tiny)plotshape(iSell, "Down Arrow", shape.triangledown, location.abovebar, color.red, 0, 0, "Sell", color.red, true, size.tiny)crossed =crossover(ema(close,par1), ema(close,par2))if crossed    l = label.new(bar_index, na, tostring(close),          color=color.green,          textcolor=color.white,         style=label.style_labelup, yloc=yloc.belowbar)         crossed2 =crossunder(ema(close,par1), ema(close,par2))if crossed2    l = label.new(bar_index, na, tostring(close),          color=color.red,          textcolor=color.white,         style=label.style_labeldown, yloc=yloc.abovebar)         plot(ema(close,par1),"EMA Short",color=color.white)plot(ema(close,par2),"EMA Long",color=color.orange)longCondition = crossover(ema(close, par1), ema(close, par2))if (longCondition)    strategy.entry("My Long Entry Id", strategy.long)shortCondition = crossunder(ema(close, par1), ema(close, par2))if (shortCondition)    strategy.entry("My Short Entry Id", strategy.short)ma1_len = input(title="MA1", type=input.integer, defval=8, minval=1, maxval=100, step=1)ma2_len = input(title="MA2", type=input.integer, defval=12, minval=1, maxval=100, step=1)o = ema(open, ma1_len)c = ema(close, ma1_len)h = ema(high, ma1_len)l = ema(low, ma1_len)tim1=input('D',"Short Time")tim2=input('W',"Long Time")ema_p=input(title="EMA Period", type=input.integer, defval=16, minval=1, maxval=100, step=1)refma = ema(close, ema_p)plot(refma, title="EMA" , linewidth=1, color=close < refma ? color.orange : color.blue)ha_t = heikinashi(syminfo.tickerid)ha_o = security(ha_t, tim2, o)ha_c = security(ha_t, tim2, c)ha_h = security(ha_t, tim2, h)ha_l = security(ha_t, tim2, l)o2 = ema(ha_o, ma2_len)c2 = ema(ha_c, ma2_len)h2 = ema(ha_h, ma2_len)l2 = ema(ha_l, ma2_len)ha_col = ha_c > ha_o ? color.red : color.greenplotshape(true, style=shape.circle, color=ha_c > ha_o ? color.green : color.red, location=location.bottom)ha_t1 = heikinashi(syminfo.tickerid)ha_o1 = security(ha_t1, tim1, o)ha_c1 = security(ha_t1, tim1, c)ha_h1 = security(ha_t1, tim1, h)ha_l1 = security(ha_t1, tim1, l)o3 = ema(ha_o1, ma2_len)c3 = ema(ha_c1, ma2_len)h3 = ema(ha_h1, ma2_len)l3 = ema(ha_l1, ma2_len)ha_col1 = ha_c1 > ha_o1 ? color.red : color.greenplotshape(true, style=shape.circle, color=ha_c1 > ha_o1 ? color.green : color.red, location=location.top)