Pine Script v5 · Strategy
Vin's Playzone Strategy
A Pine Script v5 strategy built on EMA (close, 2), RSI (close, 42) and SMA or Stoch (rsil, rsil, rsil, STOlen, 27). It has 6 order rules, 4 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. 21 settings; defaults include Source of price close, Timeframe in D and Fast EMA 13.
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 Vin's Playzone Strategy repaint?
- Yes
- At least one pattern in the source can repaint: higher-timeframe data.
- How did Vin's Playzone Strategy do on BTCUSDT 1D with default settings?
- −908.06%
- From 26 Jan 2024 to 21 Oct 2026, over 21 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Vin's Playzone Strategy run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 21 before, 17 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does Vin's Playzone Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Vin's Playzone Strategy run in Zeal Terminal?
- Yes
- It compiles in 29 ms and runs 1,000 bars in 93 ms, in the browser.
BTCUSDT · 1D · default settings
- Base-Line
- Fast EMA
- Slow EMA
- BUY
- Sell
- Long
- Short
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −908.06%
- −$9,080.60
- Buy and hold
- +102.5%
- same period
- Closed trades
- 21
- 6 won · 15 lost
- Profitable
- 28.6%
- of closed trades
- Profit factor
- 0.90
- gross profit ÷ gross loss
- Max drawdown
- 3,570.52%
- −$39,105.70
One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A long 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
ta.ema(xcross, 1) ignores the settings line 26
Line 26 hard-codes 1 where line 22 uses “Smoothing period”. Changing those settings moves one band but not this one.
ta.ema(xcross, 1)ta.ema(xcross, smooter) -
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.
-
Note
Uses an argument v6 removed
when = on line 89, 90, 91, 93, 94, 95. The upgraded version below moves each call inside an if block.
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 |
|---|---|---|---|
| Source of price | close | source | xcross efast eslow ema3x |
| Fixed Timeframe? | true | bool | efast eslow |
| Timeframe in | D | timeframe | efast eslow ema3x |
| Fast EMA | 13 | int | efast |
| Slow EMA | 26 | int | eslow |
| Base-Line | 60 | int | ema3x |
| Smoothing period | 2 | int | xcross efast eslow ema3x |
| Fill Bar Color | false | bool | barcolor |
| Show Green-Red EMA? | true | bool | Fast EMA Slow EMA |
| Show Buy-Sell signal? | true | bool | BUY Sell |
| Show Base-line? | true | bool | Base-Line |
| Fixed Base-line? | true | bool | ema3x |
| Show Long-Short? | true | bool | plotshape |
| RSI Smoothing | 3 | int · min 0 · max 3 | buycon1 sellcon1 plotshape |
| StochRSI smooth K | 27 | int · min 1 | K |
| StochRSI smooth D | 18 | int · min 1 | D |
| RSI length | 42 | int · min 1 | rsil |
| Stochastic length | 42 | int · min 1 | K |
| Source for StochasticRSI | close | source | rsil |
| Oversold Threshold | 30 | float · min 0.00 | iff_1 iff_2 |
| overbought Threshold | 70 | float · min 0.00 | iff_3 iff_4 |
What it calculates
- EMASource of price (close), Smoothing period (2)
xcross · line 22 - EMArequest.security(syminfo.tickerid, tfn, ta.ema(srcf, ema1), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on), Smoothing period (2)
efast · line 23 - EMArequest.security(syminfo.tickerid, tfn, ta.ema(srcf, ema2), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on), Smoothing period (2)
eslow · line 24 - EMArequest.security(syminfo.tickerid, tfn, ta.ema(srcf, ema3), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on), Smoothing period (2)
ema3x · line 25 - EMAxcross, 1
emabl · line 26 - RSISource for StochasticRSI (close), RSI length (42)
rsil · line 63 - SMA / Stochta.stoch(rsil, rsil, rsil, STOlen), StochRSI smooth K (27)
K · line 64 - SMAK, StochRSI smooth D (18)
D · line 65 - CrossoverK, D
crossover_1 · line 66 - CrossoverK, D
crossover_2 · line 67 - CrossunderK, D
crossunder_1 · line 71 - CrossunderK, D
crossunder_2 · line 72
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 Long long | buycon and buyfirm | On | 89 |
| Open Long long | buycon1 and buyfirm | On | 90 |
| Close Long | sell or Bear | On | 91 |
| Open Short short | sellcon and sellfirm | On | 93 |
| Open Short short | sellcon1 and sellfirm | On | 94 |
| Close Short | buy or Bull | On | 95 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- CheckHigher-timeframe data3 request.security call(s) use lookahead_on (line 23, 24, 25). Without a [1] offset this reads future bars in history.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −908.1% | +102.5% | 21 | 29% | 0.90 | 3,570.5% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −54.6% | +5.5% | 3 | 33% | 0.76 | 169.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +60.8% | +9.8% | 19 | 32% | 1.16 | 126.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +84.1% | +8.4% | 2 | 100% | — | 8.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +4.9% | +16.7% | 21 | 33% | 1.20 | 9.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +2.0% | +21.5% | 4 | 25% | 2.72 | 1.4% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +18.0% | +148.3% | 20 | 20% | 1.32 | 34.2% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +18.2% | +17.1% | 2 | 100% | — | 1.6% | 8 May 2026 – 21 Oct 2026 |
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 | 40% | $3,401.12 |
| Sideways market | 10 | 20% | −$14,887.20 |
| Falling market | 6 | 33% | $2,405.47 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
53,689.5%
The 95th percentile of the worst drawdown when the same 21 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 151.7% to 53,689.5%; the tick is what actually happened, 3,170.3%. Order luck alone moves it this much.
All 21 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 19 May 2024 66,915.20 | 18 Jun 2024 66,504.30 | 30 | −$410.87 |
| long | 20 Jul 2024 66,660.00 | 6 Aug 2024 54,018.80 | 17 | −$12,641.20 |
| short | 6 Aug 2024 54,018.80 | 26 Aug 2024 64,220.00 | 20 | −$10,201.20 |
| long | 26 Aug 2024 64,220.00 | 30 Aug 2024 59,359.00 | 4 | −$4,860.99 |
| short | 30 Aug 2024 59,359.00 | 20 Sep 2024 62,948.00 | 21 | −$3,589.00 |
| long | 20 Sep 2024 62,948.00 | 31 Dec 2024 92,792.10 | 102 | $29,844.10 |
| long | 7 Jan 2025 102,236.00 | 10 Jan 2025 92,552.50 | 3 | −$9,683.11 |
| long | 17 Jan 2025 99,987.30 | 7 Feb 2025 96,554.40 | 21 | −$3,432.95 |
| short | 7 Feb 2025 96,554.40 | 21 Apr 2025 85,179.20 | 73 | $11,375.10 |
| long | 27 Jun 2025 106,947.00 | 22 Aug 2025 112,500.00 | 56 | $5,552.94 |
| short | 22 Aug 2025 112,500.00 | 15 Sep 2025 115,268.00 | 24 | −$2,768.01 |
| long | 15 Sep 2025 115,268.00 | 26 Sep 2025 108,994.00 | 11 | −$6,273.52 |
| short | 26 Sep 2025 108,994.00 | 3 Oct 2025 120,529.00 | 7 | −$11,534.90 |
| long | 3 Oct 2025 120,529.00 | 16 Oct 2025 110,763.00 | 13 | −$9,766.07 |
| short | 16 Oct 2025 110,763.00 | 6 Jan 2026 93,859.70 | 82 | $16,903.60 |
| long | 6 Jan 2026 93,859.70 | 25 Jan 2026 89,225.30 | 19 | −$4,634.37 |
| short | 25 Jan 2026 89,225.30 | 17 Mar 2026 74,884.70 | 51 | $14,340.70 |
| short | 28 Mar 2026 66,407.30 | 10 Apr 2026 71,788.00 | 13 | −$5,380.70 |
| long | 10 Apr 2026 71,788.00 | 25 May 2026 77,065.00 | 45 | $5,276.98 |
| short | 3 Aug 2026 63,570.00 | 8 Aug 2026 64,923.20 | 5 | −$1,353.19 |
| short | 14 Aug 2026 63,490.90 | 20 Aug 2026 69,334.80 | 6 | −$5,843.92 |
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 |
|---|---|---|---|---|---|
| Vin's Playzone Strategy this page | — | v5 strategy | −908.1% | 21 | 3,570.5% |
| RSI Mean Reversion Bot Strategy by Solutions1978 | rsi ema stoch sma | v4 strategy | No trades on this market | ||
| MACD, RSI, & RVOL Strategy by BobBarker42069 | rsi ema sma | v4 strategy | +32.6% | 1 | 1.5% |
| IFR2 - RSI2 by jocker.soad | rsi sma ema | v4 strategy | No trades on this market | ||
| Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) by CheatCode1 | ema rsi stoch | v5 strategy | −3.0% | 72 | 45.4% |
| Stoch-RSI 4h-1h-15min by MoonFlag | ema rsi sma stoch | v4 strategy | No trades on this market | ||
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.
- 6 strategy calls use the when = argument (line 89, 90, 91, 93, 94, 95). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 13 settings use the untyped input() (line 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 60). 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 21 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 7: input() → input.source()
- Line 8: input() → input.bool()
- Line 10: input() → input.int()
- Line 11: input() → input.int()
- Line 12: input() → input.int()
- Line 13: input() → input.int()
13 more edits
- Line 14: input() → input.bool()
- Line 15: input() → input.bool()
- Line 16: input() → input.bool()
- Line 17: input() → input.bool()
- Line 18: input() → input.bool()
- Line 19: input() → input.bool()
- Line 60: input() → input.source()
- Line 89: when = buycon and buyfirm → if block
- Line 90: when = buycon1 and buyfirm → if block
- Line 91: when = sell or Bear → if block
- Line 93: when = sellcon and sellfirm → if block
- Line 94: when = sellcon1 and sellfirm → if block
- Line 95: when = buy or Bull → if block
⋯//variable-srcf = input(title='Source of price', defval=close)+srcf = input.source(title='Source of price', defval=close)-tffix = input(title='Fixed Timeframe?', defval=true)+tffix = input.bool(title='Fixed Timeframe?', defval=true)tfn = input.timeframe(title='Timeframe in', defval='D')-ema1 = input(title='Fast EMA', defval=13)+ema1 = input.int(title='Fast EMA', defval=13)-ema2 = input(title='Slow EMA', defval=26)+ema2 = input.int(title='Slow EMA', defval=26)-ema3 = input(title='Base-Line', defval=60)+ema3 = input.int(title='Base-Line', defval=60)-smooter = input(title='Smoothing period', defval=2)+smooter = input.int(title='Smoothing period', defval=2)-fillbar = input(title='Fill Bar Color', defval=false)+fillbar = input.bool(title='Fill Bar Color', defval=false)-emasw = input(title='Show Green-Red EMA?', defval=true)+emasw = input.bool(title='Show Green-Red EMA?', defval=true)-bssw = input(title='Show Buy-Sell signal?', defval=true)+bssw = input.bool(title='Show Buy-Sell signal?', defval=true)-blsw = input(title='Show Base-line?', defval=true)+blsw = input.bool(title='Show Base-line?', defval=true)-fxbl = input(title='Fixed Base-line?', defval=true)+fxbl = input.bool(title='Fixed Base-line?', defval=true)-plotmm = input(title='Show Long-Short?', defval=true)+plotmm = input.bool(title='Show Long-Short?', defval=true)plotmmsm = input.int(title='RSI Smoothing', defval=3, minval=0, maxval=3)⋯STOlen = input.int(42, 'Stochastic length', minval=1)-SRsrc = input(close, 'Source for StochasticRSI')+SRsrc = input.source(close, 'Source for StochasticRSI')OSlel = input.float(30, 'Oversold Threshold', minval=0.00)⋯//Long-strategy.entry('Long', strategy.long, when= buycon and buyfirm , comment='Buy', alert_message='Buy Now!')+if buycon and buyfirm+ strategy.entry('Long', strategy.long , comment='Buy', alert_message='Buy Now!')-strategy.entry('Long', strategy.long, when= buycon1 and buyfirm , comment='Long', alert_message='Buy More!')+if buycon1 and buyfirm+ strategy.entry('Long', strategy.long , comment='Long', alert_message='Buy More!')-strategy.close('Long', when= sell or Bear, comment='Stop-L', alert_message='Take profit Long')+if sell or Bear+ strategy.close('Long', comment='Stop-L', alert_message='Take profit Long')//Short-strategy.entry('Short', strategy.short, when= sellcon and sellfirm , comment='Sell', alert_message='Sell Now!')+if sellcon and sellfirm+ strategy.entry('Short', strategy.short , comment='Sell', alert_message='Sell Now!')-strategy.entry('Short', strategy.short, when= sellcon1 and sellfirm , comment='Short', alert_message='Sell More!')+if sellcon1 and sellfirm+ strategy.entry('Short', strategy.short , comment='Short', alert_message='Sell More!')-strategy.close('Short', when= buy or Bull, comment='Stop-S', alert_message='Take profit Short')+if buy or Bull+ strategy.close('Short', comment='Stop-S', alert_message='Take profit Short')Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 21 before, 17 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯//base-on CDC ActionZone By Piriya a simple 2EMA and is most suitable for use with medium volatility market-//@version=5+//@version=6strategy(title='Playzone', shorttitle='VXIZ', overlay=true, initial_capital=1000)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 29 ms | With a workaround 1,000 bars in 93 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
“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/// © Vvaz_//base-on CDC ActionZone By Piriya a simple 2EMA and is most suitable for use with medium volatility market//@version=5strategy(title='Playzone', shorttitle='VXIZ', overlay=true, initial_capital=1000)//variablesrcf = input(title='Source of price', defval=close)tffix = input(title='Fixed Timeframe?', defval=true)tfn = input.timeframe(title='Timeframe in', defval='D')ema1 = input(title='Fast EMA', defval=13)ema2 = input(title='Slow EMA', defval=26)ema3 = input(title='Base-Line', defval=60)smooter = input(title='Smoothing period', defval=2)fillbar = input(title='Fill Bar Color', defval=false)emasw = input(title='Show Green-Red EMA?', defval=true)bssw = input(title='Show Buy-Sell signal?', defval=true)blsw = input(title='Show Base-line?', defval=true)fxbl = input(title='Fixed Base-line?', defval=true)plotmm = input(title='Show Long-Short?', defval=true)plotmmsm = input.int(title='RSI Smoothing', defval=3, minval=0, maxval=3)//emaxcross = ta.ema(srcf, smooter)efast = tffix ? ta.ema(request.security(syminfo.tickerid, tfn, ta.ema(srcf, ema1), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on), smooter) : ta.ema(xcross, ema1)eslow = tffix ? ta.ema(request.security(syminfo.tickerid, tfn, ta.ema(srcf, ema2), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on), smooter) : ta.ema(xcross, ema2)ema3x = fxbl ? ta.ema(request.security(syminfo.tickerid, tfn, ta.ema(srcf, ema3), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on), smooter) : ta.ema(xcross, ema3)emabl = ta.ema(xcross, 1)//ZoneBull = efast > eslowBear = efast < eslowG1 = Bull and xcross > efast //buyG2 = Bear and xcross > efast and xcross > eslow //pre-buy1G3 = Bear and xcross > efast and xcross < eslow //pre-buy2R1 = Bear and xcross < efast //sellR2 = Bull and xcross < efast and xcross < eslow //pre-sell1R3 = Bull and xcross < efast and xcross > eslow //pre-sell2//colorbcl = G1 ? color.green : G2 ? color.yellow : G3 ? color.orange : R1 ? color.red : R2 ? color.orange : R3 ? color.yellow : color.blackbarcolor(color=fillbar ? bcl : na)//plotsline1 = plot(blsw ? ema3x : na, 'Base-Line', color=color.new(color.yellow, 0))line2 = plot(emasw ? efast : na, 'Fast EMA', color=color.new(color.green, 0))line3 = plot(emasw ? eslow : na, 'Slow EMA', color=color.new(color.red, 30))fillcl = Bull ? color.new(color.green, 80) : Bear ? color.new(color.red, 80) : color.new(color.black, 99)fill(line2, line3, fillcl )//actionsbuywhen = G1 and G1[1] == 0sellwhen = R1 and R1[1] == 0bullish = ta.barssince(buywhen) < ta.barssince(sellwhen)bearish = ta.barssince(sellwhen) < ta.barssince(buywhen)buy = bearish[1] and buywhensell = bullish[1] and sellwhen//plot trendplotshape(bssw ? buy : na, style=shape.diamond, title='BUY', location=location.belowbar, color=color.new(color.green, 0), size=size.tiny)plotshape(bssw ? sell : na, style=shape.diamond, title='Sell', location=location.abovebar, color=color.new(color.red, 0), size=size.tiny)// Momentum Signal using StochRSIsmoothK = input.int(27, 'StochRSI smooth K', minval=1)smoothD = input.int(18, 'StochRSI smooth D', minval=1)RSIlen = input.int(42, 'RSI length', minval=1)STOlen = input.int(42, 'Stochastic length', minval=1)SRsrc = input(close, 'Source for StochasticRSI')OSlel = input.float(30, 'Oversold Threshold', minval=0.00)OBlel = input.float(70, 'overbought Threshold', minval=0.00)rsil = ta.rsi(SRsrc, RSIlen)K = ta.sma(ta.stoch(rsil, rsil, rsil, STOlen), smoothK)D = ta.sma(K, smoothD)crossover_1 = ta.crossover(K, D)crossover_2 = ta.crossover(K, D)iff_1 = D > OSlel and crossover_2 ? 2 : 0iff_2 = D < OSlel and crossover_1 ? 4 : iff_1buymore = bullish ? iff_2 : 0crossunder_1 = ta.crossunder(K, D)crossunder_2 = ta.crossunder(K, D)iff_3 = D < OBlel and crossunder_2 ? 2 : 0iff_4 = D > OBlel and crossunder_1 ? 4 : iff_3sellmore = bearish ? iff_4 : 0//plot momentumplotshape(plotmm ? buymore > plotmmsm ? buymore : na : na, 'Long', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny)plotshape(plotmm ? sellmore > plotmmsm ? sellmore : na : na, 'Short', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny)//stratgy excuter//conditionbuycon = buysellcon = sellbuycon1 = buymore > plotmmsmsellcon1 = sellmore > plotmmsm//confirm_trendbuyfirm = emabl >= ema3x and Bullsellfirm = emabl <= ema3x and Bear//Longstrategy.entry('Long', strategy.long, when= buycon and buyfirm , comment='Buy', alert_message='Buy Now!')strategy.entry('Long', strategy.long, when= buycon1 and buyfirm , comment='Long', alert_message='Buy More!')strategy.close('Long', when= sell or Bear, comment='Stop-L', alert_message='Take profit Long')//Shortstrategy.entry('Short', strategy.short, when= sellcon and sellfirm , comment='Sell', alert_message='Sell Now!')strategy.entry('Short', strategy.short, when= sellcon1 and sellfirm , comment='Short', alert_message='Sell More!')strategy.close('Short', when= buy or Bull, comment='Stop-S', alert_message='Take profit Short')