Pine Script v5 · Strategy
5 Minute Scalping Strategy
A Pine Script v5 strategy built on SMA or EMA (close, 12), EMA (close, 9) and SMA (srcBB, 94). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 31 settings; defaults include Fast Length 12, Slow Length 26 and Source close.
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 5 Minute Scalping Strategy repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did 5 Minute Scalping Strategy 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.
- Does 5 Minute Scalping Strategy 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.
- Does 5 Minute Scalping Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 84, 92.
- Does 5 Minute Scalping Strategy run in Zeal Terminal?
- Yes
- It compiles in 29 ms and runs 1,000 bars in 62 ms, in the browser.
BTCUSDT · 1D · default settings
- Zero Line
- EMA9
- EMA50
- EMA200
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs BINANCE:BTCUSDT 1 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, $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.
-
Check
7 settings do nothing
“MACD Line ”, “Signal Line ”, “Above Grow”, “Fall”, “Below Grow”, “Fall”, “Offset” are declared but never read.
-
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 |
|---|---|---|---|
| Fast Length | 12 | int | fast_ma |
| Slow Length | 26 | int | slow_ma |
| Source | close | source | fast_ma slow_ma |
| Signal Smoothing | 9 | int · min 1 · max 50 | signal |
| Oscillator MA Type | EMA | string · options ["SMA", "EMA"] | fast_ma slow_ma |
| Signal Line MA Type | EMA | string · options ["SMA", "EMA"] | signal |
| Length | 9 | int · min 1 | out1 |
| Source | close | source | out1 |
| Offset | 0 | int · min -500 · max 500 | EMA9 |
| Length | 50 | int · min 1 | out2 |
| Source | close | source | out2 |
| Offset | 0 | int · min -500 · max 500 | EMA50 |
| Length | 200 | int · min 1 | out3 |
| Source | close | source | out3 |
| Offset | 0 | int · min -500 · max 500 | EMA200 |
| LengthBB Long | 94 | int · min 1 | basisBBLong devBBLong |
| LengthBB Short | 83 | int · min 1 | basisBBShort devBBShort |
| StdDev | 2.0 | float · min 0.001 · max 50 | devBBLong devBBShort |
| Offset | 0 | int · min -500 · max 500 | unused |
| Rsi Length Long | 11 | int · min 1 | rlong |
| Rsi Length Short | 29 | int · min 1 | rshort |
| Take Profit % | 0.5 | float · step 0.1 | longprofit shortprofit |
| Stop Loss % | 0.3 | float · step 0.1 | longstop shortstop |
| MacdTick Low | -10 | int | entry Long line 79 |
| MacdTick High | 35 | int | entry short line 87 |
| Color Settings | |||
| MACD Line | #2962FF | value | unused |
| Signal Line | #FF6D00 | value | unused |
| Histogram | |||
| Above Grow | #26A69A | value | unused |
| Fall | #B2DFDB | value | unused |
| Below Grow | #FFCDD2 | value | unused |
| Fall | #FF5252 | value | unused |
What it calculates
- SMA / EMASource (close), Fast Length (12) · chosen by Oscillator MA Type
fast_ma · line 19 - SMA / EMASource (close), Slow Length (26) · chosen by Oscillator MA Type
slow_ma · line 20 - SMA / EMAmacd, Signal Smoothing (9) · chosen by Signal Line MA Type
signal · line 22 - EMASource (close), Length (9)
out1 · line 31 - EMASource (close), Length (50)
out2 · line 36 - EMASource (close), Length (200)
out3 · line 41 - SMAsrcBB, LengthBB Long (94)
basisBBLong · line 50 - SMAsrcBB, LengthBB Short (83)
basisBBShort · line 51 - StdevsrcBB, LengthBB Long (94)
devBBLong · line 52 - StdevsrcBB, LengthBB Short (83)
devBBShort · line 53 - RSIclose, Rsi Length Long (11)
rlong · line 61 - RSIclose, Rsi Length Short (29)
rshort · line 63
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 | (longCondition and long and rsilong and hist_1m <= longhight) | On | 80 |
| Exit close long stop and limit | (strategy.position_size>0) | On | 84 |
| Open short short | (shortCondition and short and rsishort and hist_1m >= shorthight) | On | 88 |
| Exit close short stop and limit | (strategy.position_size<0) | On | 92 |
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.
- ClearHigher-timeframe data1 request.security call(s), none with lookahead on.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationreads realtime-only state. Live values can differ from history.
- 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 1, 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 |
|---|---|---|---|---|---|
| 5 Minute Scalping Strategy this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| Take Profit On Trend (by BHD_Trade_Bot) by BHD_Trade_Bot | ema rsi stdev sma | v4 strategy | +54.8% | 9 | 13.1% |
| Bollinger Band + RSI + ADX + MACD + Heikinashi by TradeUsingPivots | sma stdev rsi ema | v4 strategy | No trades on this market | ||
| RSI Rising Crypto Trending Strategy by exlux99 | sma stdev ema rsi | v4 strategy | No trades on this market | ||
| [KL] Bollinger bands + RSI Strategy by DojiEmoji | sma stdev ema rsi | v4 strategy | +28.2% | 30 | 14.7% |
| [KL] Bollinger Bands Consolidation Strategy by DojiEmoji | sma stdev ema 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.
- 14 settings use the untyped input() (line 5, 6, 7, 12, 13, 14, 15, 16, 17, 29, 34, 39, 78, 86). 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
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 5: input() → input.int()
- Line 6: input() → input.int()
- Line 7: input() → input.source()
- Line 12: input() → input.color()
- Line 13: input() → input.color()
- Line 14: input() → input.color()
8 more edits
- Line 15: input() → input.color()
- Line 16: input() → input.color()
- Line 17: input() → input.color()
- Line 29: input() → input.source()
- Line 34: input() → input.source()
- Line 39: input() → input.source()
- Line 78: input() → input.int()
- Line 86: input() → input.int()
⋯strategy("5 Minute Scalp", overlay=true, margin_long=100, margin_short=100)-fast_length = input(title="Fast Length", defval=12)+fast_length = input.int(title="Fast Length", defval=12)-slow_length = input(title="Slow Length", defval=26)+slow_length = input.int(title="Slow Length", defval=26)-src = input(title="Source", defval=close)+src = input.source(title="Source", defval=close)signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9)⋯// Plot colors-col_macd = input(#2962FF, "MACD Line ", group="Color Settings", inline="MACD")+col_macd = input.color(#2962FF, "MACD Line ", group="Color Settings", inline="MACD")-col_signal = input(#FF6D00, "Signal Line ", group="Color Settings", inline="Signal")+col_signal = input.color(#FF6D00, "Signal Line ", group="Color Settings", inline="Signal")-col_grow_above = input(#26A69A, "Above Grow", group="Histogram", inline="Above")+col_grow_above = input.color(#26A69A, "Above Grow", group="Histogram", inline="Above")-col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")+col_fall_above = input.color(#B2DFDB, "Fall", group="Histogram", inline="Above")-col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")+col_grow_below = input.color(#FFCDD2, "Below Grow", group="Histogram", inline="Below")-col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")+col_fall_below = input.color(#FF5252, "Fall", group="Histogram", inline="Below")// Calculating⋯len1 = input.int(9, minval=1, title="Length")-src1 = input(close, title="Source")+src1 = input.source(close, title="Source")offset1 = input.int(title="Offset", defval=0, minval=-500, maxval=500)⋯len2 = input.int(50, minval=1, title="Length")-src2 = input(close, title="Source")+src2 = input.source(close, title="Source")offset2 = input.int(title="Offset", defval=0, minval=-500, maxval=500)⋯len3 = input.int(200, minval=1, title="Length")-src3 = input(close, title="Source")+src3 = input.source(close, title="Source")offset3 = input.int(title="Offset", defval=0, minval=-500, maxval=500)⋯longCondition = hist_1m <= lowerBB-longhight = input(defval=-10,title = "MacdTick Low")+longhight = input.int(defval=-10,title = "MacdTick Low")if (longCondition and long and rsilong and hist_1m <= longhight) ⋯shortCondition = hist_1m >= upperBB-shorthight = input(defval=35,title = "MacdTick High")+shorthight = input.int(defval=35,title = "MacdTick High")if (shortCondition and short and rsishort and hist_1m >= shorthight)⋯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.
⋯// © pluckyCraft54926-//@version=5+//@version=6strategy("5 Minute Scalp", overlay=true, margin_long=100, margin_short=100)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 29 ms | Yes 1,000 bars in 62 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“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/// © pluckyCraft54926//@version=5strategy("5 Minute Scalp", overlay=true, margin_long=100, margin_short=100)fast_length = input(title="Fast Length", defval=12)slow_length = input(title="Slow Length", defval=26)src = input(title="Source", defval=close)signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9)sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"])sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])// Plot colorscol_macd = input(#2962FF, "MACD Line ", group="Color Settings", inline="MACD")col_signal = input(#FF6D00, "Signal Line ", group="Color Settings", inline="Signal")col_grow_above = input(#26A69A, "Above Grow", group="Histogram", inline="Above")col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")// Calculatingfast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)macd = fast_ma - slow_masignal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)hist = macd - signalhist_1m = request.security(syminfo.tickerid,"1",hist [barstate.isrealtime ? 1 : 0])hline(0, "Zero Line", color=color.new(#787B86, 50))//////////////////////////////////////////////////////plotting emas on the chartlen1 = input.int(9, minval=1, title="Length")src1 = input(close, title="Source")offset1 = input.int(title="Offset", defval=0, minval=-500, maxval=500)out1 = ta.ema(src1, len1)plot(out1, title="EMA9", color=color.blue, offset=offset1)len2 = input.int(50, minval=1, title="Length")src2 = input(close, title="Source")offset2 = input.int(title="Offset", defval=0, minval=-500, maxval=500)out2 = ta.ema(src2, len2)plot(out2, title="EMA50", color=color.yellow, offset=offset2)len3 = input.int(200, minval=1, title="Length")src3 = input(close, title="Source")offset3 = input.int(title="Offset", defval=0, minval=-500, maxval=500)out3 = ta.ema(src3, len3)plot(out3, title="EMA200", color=color.white, offset=offset3)////////////////////////////////////////////////////////////////////Setting up the BB/////////////////////////////////////////////////////////////srcBB = hist_1mlengthBBLong = input.int(94,title = "LengthBB Long", minval=1)lengthBBShort = input.int(83,title = "LengthBB Short", minval=1)multBB = input.float(2.0, minval=0.001, maxval=50, title="StdDev")basisBBLong = ta.sma(srcBB, lengthBBLong)basisBBShort = ta.sma(srcBB, lengthBBShort)devBBLong = multBB * ta.stdev(srcBB, lengthBBLong)devBBShort = multBB * ta.stdev(srcBB, lengthBBShort)upperBB = basisBBShort + devBBShortlowerBB = basisBBLong - devBBLongoffsetBB = input.int(0, "Offset", minval = -500, maxval = 500)///////////////////////////////////////////aetting up rsi///////////////////////////////////////////rsilengthlong = input.int(defval = 11, title = "Rsi Length Long", minval = 1)rlong=ta.rsi(close,rsilengthlong)rsilengthshort = input.int(defval = 29, title = "Rsi Length Short", minval = 1)rshort=ta.rsi(close,rsilengthshort)/////////////////////////////Only taking long and shorts, if RSI is above 51 or bellow 49rsilong = rlong >= 51rsishort = rshort <= 49////////////////////////////////////////only taking trades if all 3 emas are in the correct orderlong = out1 > out2 and out2 > out3short = out1 < out2 and out2 < out3//////////////////////////////////////////////////////////////////////////////////setting up TP and SLTP = input.float(defval = 0.5, title = "Take Profit %",step = 0.1) / 100SL = input.float(defval = 0.3, title = "Stop Loss %", step = 0.1) / 100longCondition = hist_1m <= lowerBBlonghight = input(defval=-10,title = "MacdTick Low")if (longCondition and long and rsilong and hist_1m <= longhight) strategy.entry("Long", strategy.long)if (strategy.position_size>0) longstop = strategy.position_avg_price * (1-SL) longprofit = strategy.position_avg_price * (1+TP) strategy.exit(id ="close long",from_entry="Long",stop=longstop,limit=longprofit)shortCondition = hist_1m >= upperBBshorthight = input(defval=35,title = "MacdTick High")if (shortCondition and short and rsishort and hist_1m >= shorthight) strategy.entry("short ", strategy.short)shortstop = strategy.position_avg_price * (1+SL)shortprofit = strategy.position_avg_price * (1-TP)if (strategy.position_size<0) strategy.exit(id ="close short",stop=shortstop,limit=shortprofit)