Pine Script v4 · Strategy
Crypto rsi cci mf stoch rsi oscillators all in one strategy
A Pine Script v4 strategy built on Change (src), RMA or Change (max(change(src), 0), 100) and SMA (src, 100). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.03% commission. 3 settings; defaults include Length 100, K 1 and D 1.
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 Crypto rsi cci mf stoch rsi oscillators all in one strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Crypto rsi cci mf stoch rsi oscillators all in one strategy do on BTCUSDT 1D with default settings?
- +1.56%
- From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Crypto rsi cci mf stoch rsi oscillators all in one strategy be converted to Pine Script v5?
- Yes
- The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
- Does Crypto rsi cci mf stoch rsi oscillators all in one strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Crypto rsi cci mf stoch rsi oscillators all in one strategy run in Zeal Terminal?
- Yes
- It compiles in 11 ms and runs 1,000 bars in 38 ms, in the browser.
BTCUSDT · 1D · default settings
- RSI
- MF
- zap
- K
- D
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +1.56%
- $15.62
- Buy and hold
- +102.5%
- same period
- Closed trades
- 3
- 1 won · 2 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 1.08
- gross profit ÷ gross loss
- Max drawdown
- 26.80%
- −$267.95
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.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
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 38, 39. The upgraded version below moves each call inside an if block.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames sum → math.sum, change → ta.change, rma → ta.rma, max → math.max, min → math.min, sma → ta.sma, dev → ta.dev, rsi → ta.rsi, stoch → ta.stoch.
- 2 strategy calls use the when = argument (line 38, 39). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 5: input(type = input.integer) → input.int()
- Line 7: sum → math.sum
- Line 7: change → ta.change
- Line 8: sum → math.sum
- Line 8: change → ta.change
13 more edits
- Line 16: rma → ta.rma
- Line 16: max → math.max
- Line 16: change → ta.change
- Line 17: rma → ta.rma
- Line 17: min → math.min
- Line 17: change → ta.change
- Line 22: sma → ta.sma
- Line 23: dev → ta.dev
- Line 27: rsi → ta.rsi
- Line 28: sma → ta.sma
- Line 28: stoch → ta.stoch
- Line 29: sma → ta.sma
- Line 38: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
⋯// © SoftKill21-//@version=4+//@version=5strategy(title="something", initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.03, pyramiding=1 )-length = input(title="Length", type=input.integer, defval=100, minval=1, maxval=2000)+length = input.int(title="Length", defval=100, minval=1, maxval=2000)src = hlc3-upper = sum(volume * (change(src) <= 0 ? 0 : src), length)+upper = math.sum(volume * (ta.change(src) <= 0 ? 0 : src), length)-lower = sum(volume * (change(src) >= 0 ? 0 : src), length)+lower = math.sum(volume * (ta.change(src) >= 0 ? 0 : src), length)_rsi(upper, lower) =>⋯mf = _rsi(upper, lower)-up = rma(max(change(src), 0), length)+up = ta.rma(math.max(ta.change(src), 0), length)-down = rma(-min(change(src), 0), length)+down = ta.rma(-math.min(ta.change(src), 0), length)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))⋯hline(50, title="zap", color=#c0c0c0)-ma = sma(src, length)+ma = ta.sma(src, length)-cci = (src - ma) / (0.015 * dev(src, length))+cci = (src - ma) / (0.015 * ta.dev(src, length))//plot(cci, "CCI", color=#996A15)⋯smoothD = input(1, "D", minval=1)-rsi1 = rsi(src, length)+rsi1 = ta.rsi(src, length)-k = sma(stoch(rsi1, rsi1, rsi1, length), smoothK)+k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, length), smoothK)-d = sma(k, smoothD)+d = ta.sma(k, smoothD)plot(k, "K", color=#0094FF)⋯plot(avg)-strategy.entry('long',1,when=long)+strategy.entry('long',strategy.long,when=long)strategy.close("long",when=short)⋯Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 25: input() → input.int()
- Line 26: input() → input.int()
- Line 38: when = long → if block
- Line 39: when = short → if block
⋯//plot(cci, "CCI", color=#996A15)-smoothK = input(1, "K", minval=1)+smoothK = input.int(1, "K", minval=1)-smoothD = input(1, "D", minval=1)+smoothD = input.int(1, "D", minval=1)rsi1 = ta.rsi(src, length)⋯plot(avg)-strategy.entry('long',strategy.long,when=long)+if long+ strategy.entry('long',strategy.long)-strategy.close("long",when=short)+if short+ strategy.close("long")//strategy.entry('short',0,when=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: 3 before, 5 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.
⋯// © SoftKill21-//@version=5+//@version=6strategy(title="something", initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.03, pyramiding=1 )⋯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 |
|---|---|---|---|
| Length | 100 | int (written input.integer) · min 1 · max 2000 | upper lower up down ma cci rsi1 k |
| K | 1 | int · min 1 | k |
| D | 1 | int · min 1 | d |
What it calculates
- Change (
change,ta.changein v5)srcupper · line 7 - Change (
change,ta.changein v5)srclower · line 8 - RMA / Change (
rma,ta.rmain v5)max(change(src), 0), Length (100)up · line 16 - RMA / Change (
rma,ta.rmain v5)-min(change(src), 0), Length (100)down · line 17 - SMA (
sma,ta.smain v5)src, Length (100)ma · line 22 - DEV (
dev,ta.devin v5)src, Length (100)cci · line 23 - RSI (
rsi,ta.rsiin v5)src, Length (100)rsi1 · line 27 - SMA / Stoch (
sma,ta.smain v5)stoch(rsi1, rsi1, rsi1, length), K (1)k · line 28 - SMA (
sma,ta.smain v5)k, D (1)d · line 29
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 | longrsi > 50 and mf > 50 and cci >50 and (k > 50 or d>50) | On | 38 |
| Close long | shortrsi<49 and mf<49 and cci<0 and (k<50 or d<50) | On | 39 |
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 | +1.6% | +102.5% | 3 | 33% | 1.08 | 26.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +20.2% | +5.5% | 3 | 33% | 5.94 | 4.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −28.7% | +9.8% | 3 | 33% | 0.32 | 54.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +45.3% | +8.4% | 1 | 100% | — | 1.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −24.5% | +16.7% | 2 | 0% | 0.00 | 35.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +45.6% | +21.5% | 2 | 100% | — | 2.8% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +2.1% | +148.3% | 3 | 33% | 1.08 | 32.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +1.2% | +17.1% | 4 | 25% | 1.06 | 20.6% | 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 60, K 2) made +49.8% before 26 Dec 2025 and −27.5% after it, worse than the defaults' 0.0% after. Tuning on the past did not carry forward. 88% of the 16 combinations made money in-sample and 0% out-of-sample.
| K ↓ · Length → | 50 | 60 | 70 | 85 | 100 | 120 | 140 | 170 |
|---|---|---|---|---|---|---|---|---|
| 1 | +29% | +23% | +6% | −6% | +2% | +8% | +24% | +41% |
| 2 | +31% | +50% | +5% | −6% | +2% | +6% | +24% | +41% |
| K ↓ · Length → | 50 | 60 | 70 | 85 | 100 | 120 | 140 | 170 |
|---|---|---|---|---|---|---|---|---|
| 1 | −32% | −22% | −24% | −23% | 0% | 0% | 0% | 0% |
| 2 | −32% | −27% | −24% | −23% | 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 | 2 | 0% | −$191.81 |
| Sideways market | 1 | 100% | $207.74 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
19.2%
The 95th percentile of the worst drawdown when the same 3 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 19.1% to 19.2%; the tick is what actually happened, 19.1%. Order luck alone moves it this much.
All 3 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 19 May 2024 66,915.20 | 8 Sep 2024 54,160.90 | 112 | −$191.09 |
| long | 16 Oct 2024 67,074.10 | 1 Mar 2025 84,349.90 | 136 | $207.74 |
| long | 6 Jun 2025 101,509.00 | 5 Nov 2025 101,497.00 | 152 | −$0.72 |
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 |
|---|---|---|---|---|---|
| Crypto rsi cci mf stoch rsi oscillators all in one strategy this page | — | v4 strategy | +1.6% | 3 | 26.8% |
| [Pt] Premarket Breakout Strategy by PtGambler | rma rsi sma | v5 strategy | No trades on this market | ||
| Stoch-RSI 4h-1h-15min by MoonFlag | rsi sma rma stoch | v4 strategy | No trades on this market | ||
| Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System by exlux99 | rsi sma rma | v4 strategy | −0.0% | 3 | 0.0% |
| CCI + EMA with RSI Cross Strategy by rwestbrookjr | rma sma dev | v5 strategy | No trades on this market | ||
| CCI Level Zone by Naruephat | sma rsi stoch | v5 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 11 ms | With a workaround 1,000 bars in 38 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as 1 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 38) 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. PineTS runs Pine Script v5 and v6 only.
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/// © SoftKill21//@version=4strategy(title="something", initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.03, pyramiding=1 )length = input(title="Length", type=input.integer, defval=100, minval=1, maxval=2000)src = hlc3upper = sum(volume * (change(src) <= 0 ? 0 : src), length)lower = sum(volume * (change(src) >= 0 ? 0 : src), length)_rsi(upper, lower) => if lower == 0 100 if upper == 0 0 100.0 - (100.0 / (1.0 + upper / lower))mf = _rsi(upper, lower)up = rma(max(change(src), 0), length)down = rma(-min(change(src), 0), length)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))plot(rsi, "RSI", color=#8E1599)plot(mf, "MF", color=#459915)hline(50, title="zap", color=#c0c0c0)ma = sma(src, length)cci = (src - ma) / (0.015 * dev(src, length))//plot(cci, "CCI", color=#996A15)smoothK = input(1, "K", minval=1)smoothD = input(1, "D", minval=1)rsi1 = rsi(src, length)k = sma(stoch(rsi1, rsi1, rsi1, length), smoothK)d = sma(k, smoothD)plot(k, "K", color=#0094FF)plot(d, "D", color=#FF6A00)avg = (rsi + mf + cci + k + d)/5long = rsi > 50 and mf > 50 and cci >50 and (k > 50 or d>50)short= rsi<49 and mf<49 and cci<0 and (k<50 or d<50)// long= avg > 100// short=avg<0plot(avg)strategy.entry('long',1,when=long)strategy.close("long",when=short)//strategy.entry('short',0,when=short)//strategy.close("short",when=exitshort)