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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| RSI Source | close | source | rsi |
| RSI Length | 20 | int · min 0 · max 200 · step 1 | rsi |
| Stoch %K Length | 55 | int · min 1 | kLine |
| Stoch %K Smoothing | 34 | int · min 1 | kLine |
| Stoch %D Smoothing | 21 | int · min 1 | dLine |
| ATR Length | 5 | int | unused |
| SuperTrend ATR Length | 10 | int | stAtr supertrend direction |
| SuperTrend Multiplier | 2.0 | float · step 0.1 | supertrend direction |
| BB Length | 20 | int | bbmultiplier bbMband |
| BB Source | close | source | bbmultiplier bbMband |
| BB Std Dev | 2.0 | float · step 0.1 | bbmultiplier |
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 - ATR5
atr · 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Buy long | LongEntry | On | 52 |
| Close Buy | closelong | On | 56 |
| Close Buy | stoplong | On | 59 |
| Open Sell long | ShortEntry | On | 62 |
| Close Sell | closeshort | On | 66 |
| Close Sell | stopshort | On | 69 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −0.0% | +102.5% | 11 | 36% | 0.30 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −0.0% | +5.5% | 14 | 57% | 0.73 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.0% | +9.8% | 6 | 50% | 3.34 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 9 | 67% | 1.40 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.3% | +16.7% | 7 | 29% | 0.34 | 0.5% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.1% | +21.5% | 2 | 100% | — | 0.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.1% | +148.3% | 7 | 0% | 0.00 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 10 | 50% | 0.49 | 0.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.
| Stoch %K Length ↓ · RSI Length → | 10 | 12 | 14 | 17 | 20 | 24 | 28 | 34 |
|---|---|---|---|---|---|---|---|---|
| 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% |
| Stoch %K Length ↓ · RSI Length → | 10 | 12 | 14 | 17 | 20 | 24 | 28 | 34 |
|---|---|---|---|---|---|---|---|---|
| 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 5 | 80% | $1.53 |
| Sideways market | 2 | 0% | −$6.12 |
| Falling market | 4 | 0% | −$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.
All 11 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 2 Aug 2024 65,354.00 | 2 Aug 2024 61,498.30 | 0 | −$4.63 |
| long | 4 Nov 2024 68,776.00 | 4 Nov 2024 67,850.00 | 0 | −$1.28 |
| long | 6 Dec 2024 96,945.60 | 6 Dec 2024 99,740.80 | 0 | $1.07 |
| long | 26 Jul 2025 117,614.00 | 26 Jul 2025 117,920.00 | 0 | $0.17 |
| long | 29 Oct 2025 112,898.00 | 29 Oct 2025 110,021.00 | 0 | −$1.50 |
| long | 4 Dec 2025 93,429.90 | 4 Dec 2025 92,078.10 | 0 | −$0.75 |
| long | 10 Dec 2025 92,678.80 | 10 Dec 2025 92,015.40 | 0 | −$0.39 |
| long | 26 Feb 2026 67,988.00 | 26 Feb 2026 67,485.20 | 0 | −$0.46 |
| long | 3 Mar 2026 68,830.10 | 3 Mar 2026 68,338.00 | 0 | −$0.39 |
| long | 16 Sep 2026 75,644.50 | 16 Sep 2026 76,206.00 | 0 | $0.64 |
| long | 9 Oct 2026 81,754.50 | 9 Oct 2026 82,635.60 | 0 | $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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Golden Swing Strategy - Souradeep Dey this page | — | v5 strategy | −0.0% | 11 | 0.0% |
| AVWAP Strategy by asfbhero | rsi stoch sma stdev | v5 strategy | does not run in Zeal Terminal | ||
| [KL] Bollinger bands + RSI Strategy by DojiEmoji | sma stdev atr rsi | v4 strategy | +28.2% | 30 | 14.7% |
| 3x Supertrend and Stoch RSI by M3RZI | supertrend rsi sma atr | v4 strategy | −128.7% | 24 | 207.6% |
| Bollinger band & Volume based strategy V2 by Ayden_C | sma atr rsi stdev | v4 strategy | −0.1% | 5 | 0.2% |
| [KL] Bollinger Bands Consolidation Strategy by DojiEmoji | sma stdev atr rsi | v4 strategy | +39.1% | 33 | 19.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.
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.
⋯// © 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 17 ms | With a workaround 1,000 bars in 44 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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")