Pine Script v5 · Strategy
Scalping Trading System bot Crypto and Stocks
A Pine Script v5 strategy built on SMA (low, 25), EMA (low, 200) and TR or ATR or RMA (true). 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. 15 settings; defaults include Source low, Length SMA 25 and Length EMA 200.
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 Scalping Trading System bot Crypto and Stocks repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Scalping Trading System bot Crypto and Stocks do on BTCUSDT 1D with default settings?
- +6.49%
- From 26 Jan 2024 to 21 Oct 2026, over 5 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Scalping Trading System bot Crypto and Stocks 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: 5 before, 8 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 Scalping Trading System bot Crypto and Stocks use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Scalping Trading System bot Crypto and Stocks run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 42 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- EMA
- SMA
- TR
- SMA
- SMA
- SMA
- SMA
- SMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +6.49%
- $64,925.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 5
- 3 won · 2 lost
- Profitable
- 60.0%
- of closed trades
- Profit factor
- 13.59
- gross profit ÷ gross loss
- Max drawdown
- 1.04%
- −$10,556.70
One run with the author's default settings, $1,000,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.
-
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 39, 40. 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 | low | source | out out2 ma fast_ma slow_ma |
| Moving Averages | |||
| Length SMA | 25 | int · min 1 | out |
| Length EMA | 200 | int · min 1 | out2 |
| Keltner | |||
| Length Keltner Channel | 10 | int · min 1 | ma rangema |
| Multiplier | 2.0 | float | upper lower |
| Bands Style | Average True Range | string · options ["Average True Range", "True Range", "Range"] | rangema |
| ATR Length | 14 | int | rangema |
| Stochastic | |||
| %K Length | 10 | int · min 1 | k |
| %K Smoothing | 1 | int · min 1 | k |
| %D Smoothing | 1 | int · min 1 | d |
| MACD Fast | |||
| Fast Length MACD | 4 | int | fast_ma |
| Slow Length MACD | 34 | int | slow_ma |
| Signal Smoothing MACD | 5 | int · min 1 · max 50 | signal |
| Oscillator MA Type MACD | EMA | string · options ["SMA", "EMA"] | fast_ma slow_ma |
| Signal Line MA Type MACD | EMA | string · options ["SMA", "EMA"] | signal |
What it calculates
- SMASource (low), Length SMA (25)
out · line 9 - EMASource (low), Length EMA (200)
out2 · line 10 - SMASource (low), Length Keltner Channel (10)
ma · line 16 - TR / ATR / RMAtrue · chosen by Bands Style
rangema · line 17 - SMA / Stochta.stoch(close, high, low, periodK), %K Smoothing (1)
k · line 24 - SMAk, %D Smoothing (1)
d · line 25 - SMA / EMASource (low), Fast Length MACD (4) · chosen by Oscillator MA Type MACD
fast_ma · line 32 - SMA / EMASource (low), Slow Length MACD (34) · chosen by Oscillator MA Type MACD
slow_ma · line 33 - SMA / EMAmacd, Signal Smoothing MACD (5) · chosen by Signal Line MA Type MACD
signal · line 35
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 | longclose > out and close < upper and close > lower and hist < 0 and k < 50 and close > out2 | On | 39 |
| Open short short | shortclose < out and close < upper and close > lower and hist > 0 and k > 50 and close < out2 | On | 40 |
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.
- 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 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 | +6.5% | +102.5% | 5 | 60% | 13.59 | 1.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +1.4% | +5.5% | 6 | 33% | 5.17 | 0.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.0% | +9.8% | 5 | 60% | 1.71 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.1% | +8.4% | 2 | 50% | 20.77 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 8 | 13% | 0.22 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 8 | 25% | 2.72 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.0% | +148.3% | 8 | 25% | 0.57 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 4 | 25% | 19.95 | 0.0% | 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 (Length SMA 18, Length EMA 200) made +6.7% before 26 Dec 2025 and 0.0% after it, against 0.0% for the defaults. 78% of the 64 combinations made money in-sample and 0% out-of-sample.
| Length EMA ↓ · Length SMA → | 13 | 15 | 18 | 21 | 25 | 30 | 35 | 43 |
|---|---|---|---|---|---|---|---|---|
| 100 | 0% | −0% | +5% | +5% | +5% | +5% | +5% | +5% |
| 120 | 0% | −1% | +4% | +4% | +4% | +4% | +3% | +3% |
| 140 | 0% | −1% | +3% | +3% | +3% | +3% | +3% | +3% |
| 170 | 0% | −1% | +6% | +6% | +3% | +3% | +3% | +3% |
| 200 | 0% | +1% | +7% | +7% | +6% | +6% | +6% | +6% |
| 240 | 0% | +1% | +4% | +4% | +4% | +4% | +4% | +4% |
| 280 | 0% | −0% | +3% | +3% | +3% | +3% | +3% | +3% |
| 340 | 0% | −3% | +1% | +1% | +1% | +0% | +0% | +0% |
| Length EMA ↓ · Length SMA → | 13 | 15 | 18 | 21 | 25 | 30 | 35 | 43 |
|---|---|---|---|---|---|---|---|---|
| 100 | 0% | −3% | −3% | −3% | −3% | −3% | −3% | −3% |
| 120 | 0% | −3% | −3% | −3% | −3% | −3% | −3% | −3% |
| 140 | 0% | −4% | −3% | −3% | −3% | −3% | −3% | −3% |
| 170 | 0% | −4% | −0% | −0% | −0% | −0% | −0% | −3% |
| 200 | 0% | −1% | 0% | 0% | 0% | 0% | 0% | 0% |
| 240 | 0% | −1% | 0% | 0% | 0% | 0% | 0% | 0% |
| 280 | 0% | −1% | 0% | 0% | 0% | 0% | 0% | 0% |
| 340 | 0% | −1% | 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 | 0 | — | $0.00 |
| Sideways market | 3 | 33% | $14,231.60 |
| Falling market | 2 | 100% | $50,693.40 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
0.5%
The 95th percentile of the worst drawdown when the same 5 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.4% to 0.5%; the tick is what actually happened, 0.4%. Order luck alone moves it this much.
All 5 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 13 Aug 2024 59,346.60 | 1 Oct 2024 63,327.60 | 49 | −$3,980.96 |
| long | 1 Oct 2024 63,327.60 | 19 Mar 2025 82,715.00 | 169 | $19,387.40 |
| short | 19 Mar 2025 82,715.00 | 5 Apr 2025 83,889.90 | 17 | −$1,174.84 |
| long | 5 Apr 2025 83,889.90 | 11 Nov 2025 106,011.00 | 220 | $22,121.30 |
| short | 11 Nov 2025 106,011.00 | 2 Sep 2026 77,439.00 | 295 | $28,572.10 |
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 |
|---|---|---|---|---|---|
| Scalping Trading System bot Crypto and Stocks this page | — | v5 strategy | +6.5% | 5 | 1.0% |
| Stochastic Moving Average by LucasVivien | stoch sma ema atr | v5 strategy | +2.8% | 7 | 4.4% |
| Strategy - Trend Chaser - PSe by ElvinKennedyHernandezLatayan | tr atr rma ema sma | v5 strategy | No trades on this market | ||
| Indicators & Conditions Test Framework [DTU] by dturkuler | stoch sma tr atr | v5 strategy | does not run in Zeal Terminal | ||
| ATR with EOM and VORTEX by SoftKill21 | atr ema sma | v4 strategy | +66.2% | 22 | 29.9% |
| cATRpillar Strategy by Obi-wanClintobe | atr sma ema | v4 strategy | +1.02827e+24% | 27 | 88,097.2% |
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.
- 2 strategy calls use the when = argument (line 39, 40). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 5 settings use the untyped input() (line 5, 13, 15, 27, 28). 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 5 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.source()
- Line 13: input() → input.float()
- Line 15: input() → input.int()
- Line 27: input() → input.int()
- Line 28: input() → input.int()
- Line 39: when = long → if block
- Line 40: when = short → if block
⋯strategy(title="Scalping Trading System Crypto and Stocks", overlay=true)-src = input(low, title="Source")+src = input.source(low, title="Source")//sma and ema⋯lengthk = input.int(10, minval=1, title="Length Keltner Channel",group="Keltner")-mult = input(2.0, "Multiplier",group="Keltner")+mult = input.float(2.0, "Multiplier",group="Keltner")BandsStyle = input.string("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style",group="Keltner")-atrlength = input(14, "ATR Length",group="Keltner")+atrlength = input.int(14, "ATR Length",group="Keltner")ma = ta.sma(src, lengthk)⋯//macd 1-fast_length = input(title="Fast Length MACD", defval=4,group="MACD Fast")+fast_length = input.int(title="Fast Length MACD", defval=4,group="MACD Fast")-slow_length = input(title="Slow Length MACD", defval=34,group="MACD Fast")+slow_length = input.int(title="Slow Length MACD", defval=34,group="MACD Fast")signal_length = input.int(title="Signal Smoothing MACD", minval = 1, maxval = 50, defval = 5,group="MACD Fast")⋯short= close < out and close < upper and close > lower and hist > 0 and k > 50 and close < out2 -strategy.entry("long",strategy.long,when= long)+if long+ strategy.entry("long",strategy.long)-strategy.entry("short",strategy.short,when=short)+if short+ strategy.entry("short",strategy.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: 5 before, 8 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.
⋯// © exlux99-//@version=5+//@version=6strategy(title="Scalping Trading System Crypto and Stocks", overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | Yes 1,000 bars in 42 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/// © exlux99//@version=5strategy(title="Scalping Trading System Crypto and Stocks", overlay=true)src = input(low, title="Source")//sma and emalen = input.int(25, minval=1, title="Length SMA" , group="Moving Averages")len2 = input.int(200, minval=1, title="Length EMA", group="Moving Averages")out = ta.sma(src, len)out2 = ta.ema(src, len2)//keltnerlengthk = input.int(10, minval=1, title="Length Keltner Channel",group="Keltner")mult = input(2.0, "Multiplier",group="Keltner")BandsStyle = input.string("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style",group="Keltner")atrlength = input(14, "ATR Length",group="Keltner")ma = ta.sma(src, lengthk)rangema = BandsStyle == "True Range" ? ta.tr(true) : BandsStyle == "Average True Range" ? ta.atr(atrlength) : ta.rma(high - low, lengthk)upper = ma + rangema * multlower = ma - rangema * mult//stochperiodK = input.int(10, title="%K Length", minval=1,group="Stochastic")smoothK = input.int(1, title="%K Smoothing", minval=1,group="Stochastic")periodD = input.int(1, title="%D Smoothing", minval=1,group="Stochastic")k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)d = ta.sma(k, periodD)//macd 1fast_length = input(title="Fast Length MACD", defval=4,group="MACD Fast")slow_length = input(title="Slow Length MACD", defval=34,group="MACD Fast")signal_length = input.int(title="Signal Smoothing MACD", minval = 1, maxval = 50, defval = 5,group="MACD Fast")sma_source = input.string(title="Oscillator MA Type MACD", defval="EMA", options=["SMA", "EMA"],group="MACD Fast")sma_signal = input.string(title="Signal Line MA Type MACD", defval="EMA", options=["SMA", "EMA"],group="MACD Fast")fast_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 - signallong= close > out and close < upper and close > lower and hist < 0 and k < 50 and close > out2 short= close < out and close < upper and close > lower and hist > 0 and k > 50 and close < out2 strategy.entry("long",strategy.long,when= long)strategy.entry("short",strategy.short,when=short)