Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Golden Swing Strategy - Souradeep Dey

A Pine Script v5 strategy built on RSI (close, 20), SMA or Stoch (34) and SMA (kLine, 21). It has 6 order rules, 2 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100000 in cash and pays no commission. 11 settings; defaults include RSI Source close, RSI Length 20 and Stoch %K Length 55.

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 Golden Swing Strategy - Souradeep Dey repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 4 of 4 trades.
How did Golden Swing Strategy - Souradeep Dey do on BTCUSDT 1D with default settings?
−0.00%
From 26 Jan 2024 to 21 Oct 2026, over 11 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Golden Swing Strategy - Souradeep Dey run in Pine Script v6?
Yes
Same 11 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Golden Swing Strategy - Souradeep Dey use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Golden Swing Strategy - Souradeep Dey run in Zeal Terminal?
Yes
It compiles in 17 ms and runs 1,000 bars in 44 ms, in the browser.

BTCUSDT · 1D · default settings

  • Shape
  • Shape
  • 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$999,993$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. Zeal Terminal's engine currently reads an order side written as direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 52, 62) so the engine trades the way the script says.
Net profit
−0.00%
−$6.59
Buy and hold
+102.5%
same period
Closed trades
11
4 won · 7 lost
Profitable
36.4%
of closed trades
Profit factor
0.30
gross profit ÷ gross loss
Max drawdown
0.00%
−$9.90

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.

  • Likely bug

    ta.atr(5) ignores the settings line 20

    Line 20 hard-codes 5 where line 26 uses “SuperTrend ATR Length”. Changing those settings moves one band but not this one.

    ta.atr(5)ta.atr(atrPeriod)
  • Check

    1 setting does nothing

    “ATR Length” is declared but never read.

  • 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

    No slippage

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

Settings

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

SettingDefaultType and rangeFeeds
RSI Sourceclosesourcersi
RSI Length20int · min 0 · max 200 · step 1rsi
Stoch %K Length55int · min 1kLine
Stoch %K Smoothing34int · min 1kLine
Stoch %D Smoothing21int · min 1dLine
ATR Length5intunused
SuperTrend ATR Length10intstAtr supertrend direction
SuperTrend Multiplier2.0float · step 0.1supertrend direction
BB Length20intbbmultiplier bbMband
BB Sourceclosesourcebbmultiplier bbMband
BB Std Dev2.0float · step 0.1bbmultiplier

What it calculates

  • RSIRSI Source (close), RSI Length (20)rsi · line 8
  • SMA / Stochta.stoch(close, high, low, kLength), Stoch %K Smoothing (34)kLine · line 14
  • SMAkLine, Stoch %D Smoothing (21)dLine · line 15
  • ATR5atr · line 20
  • ATRSuperTrend ATR Length (10)stAtr · line 26
  • SupertrendSuperTrend Multiplier (2.0), SuperTrend ATR Length (10)supertrend · line 27
  • SupertrendSuperTrend Multiplier (2.0), SuperTrend ATR Length (10)direction · line 27
  • StdevBB Source (close), BB Length (20)bbmultiplier · line 38
  • SMABB Source (close), BB Length (20)bbMband · line 39

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 datarsiLenRSI Lengthsetting · 20lowlowprice datahighhighprice datakLengthStoch %K Lengthsetting · 55kSmoothStoch %K Smoothingsetting · 34dLengthStoch %D Smoothingsetting · 21high · low · closehigh · low · closeprice dataatrPeriodSuperTrend ATR Lengthsetting · 10stfactorSuperTrend Multipliersetting · 2.0bbStdDevBB Std Devsetting · 2.0bblengthBB Lengthsetting · 20hl2hl2price dataopenopenprice datarsiRSI→ rsikLineSMA / Stoch→ kLinedLineSMA→ dLineatrATR→ atrstAtrATR→ stAtrsupertrendSupertrend→ supertrenddirectionSupertrend→ directionbbmultiplierStdev→ bbmultiplierbbMbandSMA→ bbMbandstSrcstSrcvaluebodyMiddlebodyMiddlevalueupTrend, downTrendupTrend · downTrend2 valuesbbUband, bbLbandbbUband · bbLband2 valuesLongEntryLongEntryconditionShortEntryShortEntryconditioncloselongcloselongconditionstoplongstoplongconditioncloseshortcloseshortconditionstopshortstopshortconditionentry:BuyOpen Buystrategy.entryclose:BuyClose Buystrategy.closeentry:SellOpen Sellstrategy.entryclose:SellClose Sellstrategy.closeplotshape:48plotshapeplotshapeplotshape:49plotshapeplotshape

Order rules

OrderFires whenBy defaultLine
Open Buy longLongEntryOn52
Close BuycloselongOn56
Close BuystoplongOn59
Open Sell longShortEntryOn62
Close SellcloseshortOn66
Close SellstopshortOn69

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.

4/4trades 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.0%+102.5%1136%0.300.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.0%+5.5%1457%0.730.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%650%3.340.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%967%1.400.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.3%+16.7%729%0.340.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.1%+21.5%2100%—0.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.1%+148.3%70%0.000.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%1050%0.490.1%8 May 2026 – 21 Oct 2026

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

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (RSI Length 34, Stoch %K Length 28) made −0.0% before 26 Dec 2025 and −0.0% after it, worse than the defaults' +0.0% after. Tuning on the past did not carry forward. 0% of the 64 combinations made money in-sample and 22% out-of-sample.

Before 26 Dec 2025 · in-sample
Stoch %K Length ↓ · RSI Length →1012141720242834
28−0%−0%−0%−0%−0%−0%−0%−0%
33−0%−0%−0%−0%−0%−0%−0%−0%
39−0%−0%−0%−0%−0%−0%−0%−0%
47−0%−0%−0%−0%−0%−0%−0%−0%
55−0%−0%−0%−0%−0%−0%−0%−0%
66−0%−0%−0%−0%−0%−0%−0%−0%
77−0%−0%−0%−0%−0%−0%−0%−0%
94−0%−0%−0%−0%−0%−0%−0%−0%
From 26 Dec 2025 · out-of-sample
Stoch %K Length ↓ · RSI Length →1012141720242834
28−0%−0%−0%−0%−0%−0%−0%−0%
33−0%−0%−0%−0%−0%−0%−0%−0%
39−0%−0%−0%−0%−0%−0%−0%−0%
47−0%−0%−0%−0%−0%−0%−0%−0%
55−0%−0%−0%+0%+0%+0%+0%+0%
66−0%−0%−0%−0%−0%−0%−0%−0%
77−0%−0%−0%−0%+0%+0%+0%+0%
94−0%−0%−0%+0%+0%+0%+0%+0%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market580%$1.53
Sideways market20%−$6.12
Falling market40%−$2.00

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

How bad could the drawdown be?

0.0%

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

0%1%
All 11 trades
SideEntryExitBarsP&L
long2 Aug 2024 65,354.002 Aug 2024 61,498.300−$4.63
long4 Nov 2024 68,776.004 Nov 2024 67,850.000−$1.28
long6 Dec 2024 96,945.606 Dec 2024 99,740.800$1.07
long26 Jul 2025 117,614.0026 Jul 2025 117,920.000$0.17
long29 Oct 2025 112,898.0029 Oct 2025 110,021.000−$1.50
long4 Dec 2025 93,429.904 Dec 2025 92,078.100−$0.75
long10 Dec 2025 92,678.8010 Dec 2025 92,015.400−$0.39
long26 Feb 2026 67,988.0026 Feb 2026 67,485.200−$0.46
long3 Mar 2026 68,830.103 Mar 2026 68,338.000−$0.39
long16 Sep 2026 75,644.5016 Sep 2026 76,206.000$0.64
long9 Oct 2026 81,754.509 Oct 2026 82,635.600$0.93

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
Golden Swing Strategy - Souradeep Dey this page—v5 strategy−0.0%110.0%
AVWAP Strategy by asfbherorsi stoch sma stdevv5 strategydoes not run in Zeal Terminal
[KL] Bollinger bands + RSI Strategy by DojiEmojisma stdev atr rsiv4 strategy+28.2%3014.7%
3x Supertrend and Stoch RSI by M3RZIsupertrend rsi sma atrv4 strategy−128.7%24207.6%
Bollinger band & Volume based strategy V2 by Ayden_Csma atr rsi stdevv4 strategy−0.1%50.2%
[KL] Bollinger Bands Consolidation Strategy by DojiEmojisma stdev atr rsiv4 strategy+39.1%3319.6%

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.

  • 4 settings use the untyped input() (line 6, 19, 23, 36). 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 11 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.source()
  • Line 19: input() → input.int()
  • Line 23: input() → input.int()
  • Line 36: input() → input.source()
⋯// Indicator - RSI - 20-rsiSrc = input(defval = close, title = "RSI Source")+rsiSrc = input.source(defval = close, title = "RSI Source")rsiLen = input.int(defval = 20, title = "RSI Length", minval = 0, maxval = 200, step = 1)⋯// Indicator - ATR(5)-atrLength = input(5, "ATR Length")+atrLength = input.int(5, "ATR Length")atr = ta.atr(5)⋯// Indicator - SuperTrend(10,2)-atrPeriod = input(10, "SuperTrend ATR Length")+atrPeriod = input.int(10, "SuperTrend ATR Length")stSrc = hl2⋯bblength = input.int(defval = 20, title = "BB Length")-bbsource = input(defval = close, title = "BB Source")+bbsource = input.source(defval = close, title = "BB Source")bbStdDev = input.float(defval = 2.0, title = "BB Std Dev", step = 0.1)⋯

Does it run in Pine Script v6?

Yes

Same 11 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © rajm14-//@version=5+//@version=6strategy(title = "Golden Swing Strategy - Souradeep Dey", shorttitle = "GSS", overlay = true, process_orders_on_close = true, default_qty_type = strategy.cash, default_qty_value=100000, currency = currency.USD)⋯

Where it runs

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

Zeal Terminal's engine currently reads an order side written as direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 52, 62) 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.

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/// © rajm14//@version=5strategy(title = "Golden Swing Strategy - Souradeep Dey", shorttitle = "GSS", overlay = true, process_orders_on_close = true, default_qty_type = strategy.cash, default_qty_value=100000, currency = currency.USD)// Indicator - RSI - 20rsiSrc = input(defval = close, title = "RSI Source")rsiLen = input.int(defval = 20, title = "RSI Length", minval = 0, maxval = 200, step = 1)rsi = ta.rsi(rsiSrc, rsiLen)//plot(rsi)// Indicator - Stochastic (55,34,21)kLength = input.int(defval = 55, title="Stoch %K Length", minval=1)kSmooth = input.int(defval = 34, title="Stoch %K Smoothing", minval=1)dLength = input.int(defval = 21, title="Stoch %D Smoothing", minval=1)kLine = ta.sma(ta.stoch(close, high, low, kLength), kSmooth)dLine = ta.sma(kLine, dLength)// plot(kLine, color=color.red)// plot(dLine, color=color.green)// Indicator - ATR(5)atrLength = input(5, "ATR Length")atr = ta.atr(5)// plot(atr)// Indicator - SuperTrend(10,2)atrPeriod = input(10, "SuperTrend ATR Length")stSrc = hl2stfactor = input.float(2.0, "SuperTrend Multiplier", step = 0.1)stAtr = ta.atr(atrPeriod)[supertrend, direction] = ta.supertrend(stfactor, atrPeriod)bodyMiddle = (open + close) / 2upTrend = direction < 0 ? supertrend : nadownTrend = direction < 0? na : supertrend// plot(bodyMiddle, display=display.none)// plot(upTrend)// plot(downTrend)// Indicator - Bollinger Bands (20,2)bblength = input.int(defval = 20, title = "BB Length")bbsource = input(defval = close, title = "BB Source")bbStdDev = input.float(defval = 2.0, title = "BB Std Dev", step = 0.1)bbmultiplier = bbStdDev * ta.stdev(bbsource, bblength)bbMband = ta.sma(bbsource, bblength)bbUband = bbMband + bbmultiplierbbLband = bbMband - bbmultiplier// plot (bbUband, color = color.red, linewidth = 2)// plot (bbMband, color = color.black, linewidth = 2)// plot (bbLband, color = color.green, linewidth = 2)// Trade EntryLongEntry = rsi >= 50 and kLine > dLine and low < supertrend and direction < 0 and supertrend < bbMbandShortEntry = rsi <= 50 and kLine < dLine and high > supertrend and direction > 0 and supertrend > bbMbandplotshape(LongEntry, style = shape.triangleup,  text = "Long", location = location.belowbar, size = size.large, color = color.green)plotshape(ShortEntry, style = shape.triangledown,  text = "Short", location = location.abovebar, size = size.large, color = color.red)//Trade executionif LongEntry    strategy.entry(id = "Buy", direction = strategy.long, limit = close * .5 * atr)closelong = close >= strategy.position_avg_price * 2.2 * atrstoplong = close <=  strategy.position_avg_price * 1.1 * atrif closelong    strategy.close(id = "Buy")    if stoplong    strategy.close(id = "Buy")    if ShortEntry    strategy.entry(id = "Sell", direction = strategy.long, limit = close * .5 * atr)closeshort = close <= strategy.position_avg_price * 2.2 * atrstopshort = close >=  strategy.position_avg_price * 1.1 * atrif closeshort    strategy.close(id = "Sell")    if stopshort    strategy.close(id = "Sell")