Pine Script v4 · Strategy
CCU MFI + RSI + STOCH RSI
A Pine Script v4 strategy built on MFI (source, 14), RSI (source, 14) and SMA or Stoch (3). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 7 settings; defaults include RSI length 14, Mfi lenght 14 and Smooth K 3.
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 CCU MFI + RSI + STOCH RSI repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
- How did CCU MFI + RSI + STOCH RSI do on BTCUSDT 1D with default settings?
- +41.75%
- From 26 Jan 2024 to 21 Oct 2026, over 6 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can CCU MFI + RSI + STOCH RSI 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 CCU MFI + RSI + STOCH RSI use a stop loss?
- Yes
- strategy.exit sets a stop on line 33, 37.
- Does CCU MFI + RSI + STOCH RSI run in Zeal Terminal?
- Yes
- It compiles in 11 ms and runs 1,000 bars in 35 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- Plot
- HLine
- HLine
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +41.75%
- $41,753.60
- Buy and hold
- +102.5%
- same period
- Closed trades
- 6
- 3 won · 3 lost
- Profitable
- 50.0%
- of closed trades
- Profit factor
- 1.94
- gross profit ÷ gross loss
- Max drawdown
- 37.37%
- −$37,372.30
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A short 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 commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
6 settings have no label
In the settings dialog rsi_length (line 11), mfi_lenght (line 12), smoothK (line 13), smoothD (line 14), lengthRSI (line 15), lengthStoch (line 16) show an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
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 mfi → ta.mfi, rsi → ta.rsi, sma → ta.sma, stoch → ta.stoch.
v4 → v5
VerifiedSame 6 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 7: //@version=4 → //@version=5
- Line 24: mfi → ta.mfi
- Line 25: rsi → ta.rsi
- Line 26: rsi → ta.rsi
- Line 27: sma → ta.sma
- Line 27: stoch → ta.stoch
- Line 28: sma → ta.sma
⋯// © BTA crypto-//@version=4+//@version=5strategy("Crypto Crew University")⋯//lines-mfi = mfi(source, mfi_lenght)+mfi = ta.mfi(source, mfi_lenght)-rsi = rsi(source, rsi_length)+rsi = ta.rsi(source, rsi_length)-rsi1 = rsi(close, lengthRSI)+rsi1 = ta.rsi(close, lengthRSI)-k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)+k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)-d = sma(k, smoothD)+d = ta.sma(k, smoothD)longSignal = mfi<longThreshhold and rsi<longThreshhold and k<longThreshhold and d<longThreshhold? 1:-1⋯Same 6 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 11: input() → input.int()
- Line 12: input() → input.int()
- Line 13: input() → input.int()
- Line 14: input() → input.int()
- Line 15: input() → input.int()
- Line 16: input() → input.int()
⋯source = hlc3-rsi_length = input(14, minval=1)+rsi_length = input.int(14, minval=1)-mfi_lenght = input(14, minval=1)+mfi_lenght = input.int(14, minval=1)-smoothK = input(3, minval=1)+smoothK = input.int(3, minval=1)-smoothD = input(3, minval=1)+smoothD = input.int(3, minval=1)-lengthRSI = input(14, minval=1)+lengthRSI = input.int(14, minval=1)-lengthStoch = input(14, minval=1)+lengthStoch = input.int(14, minval=1)okay = "Okay"⋯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: 6 before, 6 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.
⋯// © BTA crypto-//@version=5+//@version=6strategy("Crypto Crew University")⋯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 length (no label in the script) | 14 | int · min 1 | rsi |
| Mfi lenght (no label in the script) | 14 | int · min 1 | mfi |
| Smooth K (no label in the script) | 3 | int · min 1 | k |
| Smooth D (no label in the script) | 3 | int · min 1 | d |
| Length RSI (no label in the script) | 14 | int · min 1 | rsi1 |
| Length Stoch (no label in the script) | 14 | int · min 1 | k |
| Opportunity | veryGood | value · options [okay, good, veryGood] | longThreshhold shortThreshhold |
What it calculates
- MFI (
mfi,ta.mfiin v5)source, Mfi lenght (14)mfi · line 24 - RSI (
rsi,ta.rsiin v5)source, RSI length (14)rsi · line 25 - RSI (
rsi,ta.rsiin v5)close, Length RSI (14)rsi1 · line 26 - SMA / Stoch (
sma,ta.smain v5)stoch(rsi1, rsi1, rsi1, lengthStoch), Smooth K (3)k · line 27 - SMA (
sma,ta.smain v5)k, Smooth D (3)d · line 28
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 | longSignal > 0 | On | 32 |
| Exit Long Stop Loss stop | longSignal > 0 | On | 33 |
| Open Short short | shortSignal > 0 | On | 36 |
| Exit Short Stop Loss stop | shortSignal > 0 | On | 37 |
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 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 | +41.8% | +102.5% | 6 | 50% | 1.94 | 37.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −28.5% | +5.5% | 2 | 0% | 0.00 | 30.5% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.2% | +9.8% | 5 | 40% | 1.15 | 1.6% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.6% | +8.4% | 4 | 25% | 0.25 | 0.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.1% | +16.7% | 6 | 50% | 2.79 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 3 | 33% | 0.49 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.6% | +148.3% | 6 | 50% | 2.32 | 0.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 4 | 50% | 1.41 | 0.2% | 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 | 3 | 33% | $7,181.43 |
| Sideways market | 2 | 100% | $51,598.10 |
| Falling market | 1 | 0% | −$17,025.90 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
36.2%
The 95th percentile of the worst drawdown when the same 6 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 19.5% to 36.2%; the tick is what actually happened, 27.5%. Order luck alone moves it this much.
All 6 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 14 Feb 2024 49,699.60 | 28 Feb 2024 59,639.50 | 14 | −$9,939.92 |
| short | 13 Nov 2024 87,952.00 | 16 Dec 2024 105,542.00 | 33 | −$17,590.40 |
| long | 1 Mar 2025 84,349.90 | 15 Jul 2025 119,841.00 | 136 | $35,491.20 |
| short | 15 Jul 2025 119,841.00 | 22 Nov 2025 85,129.40 | 130 | $34,711.80 |
| long | 22 Nov 2025 85,129.40 | 5 Feb 2026 68,103.50 | 75 | −$17,025.90 |
| long | 4 Jun 2026 64,142.80 | 28 Aug 2026 80,249.60 | 85 | $16,106.80 |
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 |
|---|---|---|---|---|---|
| CCU MFI + RSI + STOCH RSI this page | — | v4 strategy | +41.8% | 6 | 37.4% |
| CCI Level Zone by Naruephat | sma rsi stoch | v5 strategy | No trades on this market | ||
| 3 Indicator Strategy (StochRSI, MFI & EMA) With Safety Orders by ggekko21 | rsi sma mfi | v5 strategy | No trades on this market | ||
| AVWAP Strategy by asfbhero | rsi stoch sma | v5 strategy | does not run in Zeal Terminal | ||
| SRJ RSI Outperformer Strategy by Sapt_Jash | rsi sma | v5 strategy | +0.6% | 8 | 2.4% |
| RSI SMA Crossover Strategy by reees | rsi sma | v5 strategy | +39.8% | 42 | 30.8% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 11 ms | Yes 1,000 bars in 35 ms | Not measured |
| PineTS | No v5 and v6 only | — | 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. 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/// Crypto Crew University strategy: // Indicators: MFI, RSI, STOCH RSI// Entry criteria: long when the three are oversold, short otherwise.// Exit criteria: Take profit at Fib levels (not demonstrated here)// © BTA crypto//@version=4strategy("Crypto Crew University")//inputssource = hlc3rsi_length = input(14, minval=1)mfi_lenght = input(14, minval=1)smoothK = input(3, minval=1)smoothD = input(3, minval=1)lengthRSI = input(14, minval=1)lengthStoch = input(14, minval=1)okay = "Okay"good = "Good"veryGood = "Very good"tradingOpportunity = input(title="Opportunity", defval=veryGood, options=[okay, good, veryGood])longThreshhold = tradingOpportunity==okay? 40 : tradingOpportunity==good ? 30 : tradingOpportunity==veryGood? 20 : 0shortThreshhold = tradingOpportunity==okay? 60 : tradingOpportunity==good ? 70 : tradingOpportunity==veryGood? 80 : 0//linesmfi = mfi(source, mfi_lenght)rsi = rsi(source, rsi_length)rsi1 = rsi(close, lengthRSI)k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)d = sma(k, smoothD)longSignal = mfi<longThreshhold and rsi<longThreshhold and k<longThreshhold and d<longThreshhold? 1:-1shortSignal = mfi>shortThreshhold and rsi>shortThreshhold and k>shortThreshhold and d>shortThreshhold? 1:-1if longSignal > 0 strategy.entry("Long", strategy.long) strategy.exit(id="Long Stop Loss", stop=strategy.position_avg_price*0.8) //20% stop loss if shortSignal > 0 strategy.entry("Short", strategy.short) strategy.exit(id="Short Stop Loss", stop=strategy.position_avg_price*1.2) //20% stop lossplot(k, color=color.blue)plot(d, color=color.red)plot(rsi, color=color.yellow)plot(mfi, color=color.blue)hline(longThreshhold, color=color.gray, linestyle=hline.style_dashed)hline(shortThreshhold, color=color.gray, linestyle=hline.style_dashed)