Pine Script v4 · Strategy
[KL] RSI 14 + 10 Strategy
A Pine Script v4 strategy built on ATR (ATR_multi_len) and RSI (close, 14). It has 5 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 is one contract and pays no commission. 9 settings; defaults include Risk:[Reward] (i.e. 3) for exit 3, ATR multiplier for stop loss 2 and RSI entry 40.
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 [KL] RSI 14 + 10 Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
- How did [KL] RSI 14 + 10 Strategy do on BTCUSDT 1D with default settings?
- +4.23%
- From 26 Jan 2024 to 21 Oct 2026, over 27 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can [KL] RSI 14 + 10 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 [KL] RSI 14 + 10 Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does [KL] RSI 14 + 10 Strategy run in Zeal Terminal?
- Yes
- It compiles in 18 ms and runs 1,000 bars in 34 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +4.23%
- $4,227.63
- Buy and hold
- +102.5%
- same period
- Closed trades
- 27
- 11 won · 16 lost
- Profitable
- 40.7%
- of closed trades
- Profit factor
- 1.05
- gross profit ÷ gross loss
- Max drawdown
- 39.66%
- −$54,996.00
One run with the author's default settings, $100,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
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.
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 atr → ta.atr, max → math.max, rsi → ta.rsi.
v4 → v5
VerifiedSame 27 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 7: input(type = input.time) → input.time()
- Line 9: input(type = input.time) → input.time()
- Line 17: atr → ta.atr
- Line 19: atr → ta.atr
- Line 24: max → math.max
- Line 35: rsi → ta.rsi
- Line 36: rsi → ta.rsi
⋯// © DojiEmoji-//@version=4+//@version=5strategy("[KL] RSI 14 + 10 Strategy v2.1",overlay=true,pyramiding=1)⋯// 1) Fixed a bug (related to TSL)-backtest_timeframe_start = input(defval = timestamp("01 Apr 2016 13:30 +0000"), title = "Backtest Start Time", type = input.time)+backtest_timeframe_start = input.time(defval = timestamp("01 Apr 2016 13:30 +0000"), title = "Backtest Start Time")USE_ENDTIME = input(false,title="Define the ending period for backtests (If false, will test up to most recent candle)")-backtest_timeframe_end = input(defval = timestamp("19 Mar 2021 19:30 +0000"), title = "Backtest End Time", type = input.time)+backtest_timeframe_end = input.time(defval = timestamp("19 Mar 2021 19:30 +0000"), title = "Backtest End Time")TARGET_PROFIT_MODE = input(false,title="Exit when Risk:Reward met")⋯ATR_multi = input(2, "ATR multiplier for stop loss")-ATR_buffer = atr(ATR_multi_len) * ATR_multi+ATR_buffer = ta.atr(ATR_multi_len) * ATR_multi//plotchar(ATR_buffer, "ATR Buffer", "", location = location.top)-risk_reward_buffer = (atr(ATR_multi_len) * ATR_multi) * REWARD_RATIO+risk_reward_buffer = (ta.atr(ATR_multi_len) * ATR_multi) * REWARD_RATIOtake_profit_long = low > entry_price + risk_reward_buffer⋯var stop_loss_price = float(0)-stop_loss_price := max(stop_loss_price, close - trailing_SL_buffer)+stop_loss_price := math.max(stop_loss_price, close - trailing_SL_buffer)// plot TSL line⋯RSI_HIGH = input(70,title="RSI exit")-rsi14 = rsi(close, 14)+rsi14 = ta.rsi(close, 14)-rsi10 = rsi(close, 10)+rsi10 = ta.rsi(close, 10)// }⋯Same 27 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 8: input() → input.bool()
- Line 10: input() → input.bool()
- Line 11: input() → input.int()
- Line 13: input() → input.bool()
- Line 16: input() → input.int()
- Line 33: input() → input.int()
- Line 34: input() → input.int()
⋯backtest_timeframe_start = input.time(defval = timestamp("01 Apr 2016 13:30 +0000"), title = "Backtest Start Time")-USE_ENDTIME = input(false,title="Define the ending period for backtests (If false, will test up to most recent candle)")+USE_ENDTIME = input.bool(false,title="Define the ending period for backtests (If false, will test up to most recent candle)")backtest_timeframe_end = input.time(defval = timestamp("19 Mar 2021 19:30 +0000"), title = "Backtest End Time")-TARGET_PROFIT_MODE = input(false,title="Exit when Risk:Reward met")+TARGET_PROFIT_MODE = input.bool(false,title="Exit when Risk:Reward met")-REWARD_RATIO = input(3,title="Risk:[Reward] (i.e. 3) for exit")+REWARD_RATIO = input.int(3,title="Risk:[Reward] (i.e. 3) for exit")// Trailing stop loss {-TSL_ON = input(true,title="Use trailing stop loss")+TSL_ON = input.bool(true,title="Use trailing stop loss")var entry_price = float(0)ATR_multi_len = 26-ATR_multi = input(2, "ATR multiplier for stop loss")+ATR_multi = input.int(2, "ATR multiplier for stop loss")ATR_buffer = ta.atr(ATR_multi_len) * ATR_multi⋯// RSI {-RSI_LOW = input(40,title="RSI entry")+RSI_LOW = input.int(40,title="RSI entry")-RSI_HIGH = input(70,title="RSI exit")+RSI_HIGH = input.int(70,title="RSI exit")rsi14 = ta.rsi(close, 14)⋯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: 27 before, 25 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.
⋯// © DojiEmoji-//@version=5+//@version=6strategy("[KL] RSI 14 + 10 Strategy v2.1",overlay=true,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 |
|---|---|---|---|
| Backtest Start Time | timestamp("01 Apr 2016 13:30 +0000") | time | line 38 |
| Define the ending period for backtests (If false, will test up to most recent candle) | false | bool | line 38 |
| Backtest End Time | timestamp("19 Mar 2021 19:30 +0000") | time | line 38 |
| Exit when Risk:Reward met | false | bool | line 60 |
| Risk:[Reward] (i.e. 3) for exit | 3 | int | risk_reward_buffer |
| Use trailing stop loss | true | bool | line 27 line 54 |
| ATR multiplier for stop loss | 2 | int | ATR_buffer risk_reward_buffer |
| RSI entry | 40 | int | buy_condition |
| RSI exit | 70 | int | exit_condition |
What it calculates
- ATR (
atr,ta.atrin v5)ATR_multi_lenATR_buffer · line 17 - ATR (
atr,ta.atrin v5)ATR_multi_lenrisk_reward_buffer · line 19 - RSI (
rsi,ta.rsiin v5)close, 14rsi14 · line 35 - RSI (
rsi,ta.rsiin v5)close, 10rsi10 · line 36
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 | buy_condition | On | 51 |
| Close Long | close > entry_price | On | 56 |
| Close Long | close <= entry_price | On | 58 |
| Close Long | take_profit_long | On | 62 |
| Close Long | take_profit_long | On | 66 |
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 | +4.2% | +102.5% | 27 | 41% | 1.05 | 39.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +12.9% | +5.5% | 33 | 45% | 1.62 | 13.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.8% | +9.8% | 28 | 39% | 1.19 | 1.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 27 | 37% | 1.02 | 0.8% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.1% | +16.7% | 25 | 32% | 0.81 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 29 | 28% | 0.67 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.1% | +148.3% | 19 | 53% | 1.12 | 0.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.1% | +17.1% | 24 | 38% | 1.50 | 0.1% | 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 | 4 | 75% | $26,674.30 |
| Sideways market | 14 | 29% | −$22,436.50 |
| Falling market | 9 | 44% | −$10.25 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
43.1%
The 95th percentile of the worst drawdown when the same 27 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 21.3% to 43.1%; the tick is what actually happened, 38.2%. Order luck alone moves it this much.
All 27 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 18 Apr 2024 61,277.40 | 2 May 2024 58,365.00 | 14 | −$2,912.41 |
| long | 3 May 2024 59,060.60 | 20 Jun 2024 64,974.40 | 48 | $5,913.77 |
| long | 21 Jun 2024 64,870.00 | 25 Jun 2024 60,293.30 | 4 | −$4,576.69 |
| long | 26 Jun 2024 61,806.00 | 5 Jul 2024 57,050.00 | 9 | −$4,755.99 |
| long | 6 Jul 2024 56,628.80 | 3 Aug 2024 61,498.30 | 28 | $4,869.55 |
| long | 4 Aug 2024 60,698.00 | 6 Aug 2024 54,018.80 | 2 | −$6,679.17 |
| long | 7 Aug 2024 56,022.00 | 2 Sep 2024 57,301.80 | 26 | $1,279.77 |
| long | 6 Sep 2024 56,180.00 | 11 Oct 2024 60,326.40 | 35 | $4,146.40 |
| long | 25 Feb 2025 91,552.90 | 27 Feb 2025 84,250.10 | 2 | −$7,302.79 |
| long | 28 Feb 2025 84,708.60 | 4 Mar 2025 86,221.20 | 4 | $1,512.59 |
| long | 10 Mar 2025 80,734.50 | 7 Apr 2025 78,430.00 | 28 | −$2,304.48 |
| long | 8 Apr 2025 79,163.20 | 10 May 2025 102,972.00 | 32 | $23,808.80 |
| long | 23 Jun 2025 100,964.00 | 15 Jul 2025 119,841.00 | 22 | $18,877.30 |
| long | 3 Aug 2025 112,546.00 | 16 Aug 2025 117,342.00 | 13 | $4,795.69 |
| long | 26 Aug 2025 110,112.00 | 26 Sep 2025 108,994.00 | 31 | −$1,117.49 |
| long | 27 Sep 2025 109,643.00 | 11 Oct 2025 112,774.00 | 14 | $3,131.03 |
| long | 12 Oct 2025 110,644.00 | 18 Oct 2025 106,432.00 | 6 | −$4,212.72 |
| long | 19 Oct 2025 107,185.00 | 4 Nov 2025 106,583.00 | 16 | −$601.95 |
| long | 5 Nov 2025 101,497.00 | 15 Nov 2025 94,594.00 | 10 | −$6,903.23 |
| long | 16 Nov 2025 95,596.20 | 21 Nov 2025 86,637.20 | 5 | −$8,959.01 |
| long | 22 Nov 2025 85,129.40 | 21 Jan 2026 88,427.70 | 60 | $3,298.24 |
| long | 26 Jan 2026 86,670.40 | 1 Feb 2026 78,741.10 | 6 | −$7,929.26 |
| long | 2 Feb 2026 76,968.20 | 6 Feb 2026 62,909.90 | 4 | −$14,058.30 |
| long | 8 Feb 2026 69,289.40 | 28 Mar 2026 66,407.30 | 48 | −$2,882.09 |
| long | 28 May 2026 74,449.30 | 3 Jun 2026 66,760.80 | 6 | −$7,688.47 |
| long | 4 Jun 2026 64,142.80 | 25 Jun 2026 61,078.00 | 21 | −$3,064.75 |
| long | 26 Jun 2026 59,794.60 | 22 Aug 2026 78,338.00 | 57 | $18,543.40 |
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 |
|---|---|---|---|---|---|
| [KL] RSI 14 + 10 Strategy this page | — | v4 strategy | +4.2% | 27 | 39.7% |
| SuperTREX strategy by RafaelZioni | rsi atr | v4 strategy | −3.8% | 3 | 6.1% |
| MA cross strategy by Glenn234 | rsi atr | v5 strategy | −606.2% | 35 | 656.0% |
| VWMA_withATRstops_strategy by ediks123 | rsi atr | v4 strategy | No trades on this market | ||
| Mathias & Christer Timeframe RSI by mattehalen | rsi atr | v4 strategy | −0.7% | 18 | 0.7% |
| Estrategia Larry Connors [JoseMetal] by JoseMetal | rsi atr | v5 strategy | +2.7% | 24 | 2.4% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | With a workaround 1,000 bars in 34 ms | Not measured |
| PineTS | No v5 and v6 only | — | 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. 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/// © DojiEmoji//@version=4strategy("[KL] RSI 14 + 10 Strategy v2.1",overlay=true,pyramiding=1)// changes in Version 2.1:// 1) Fixed a bug (related to TSL)backtest_timeframe_start = input(defval = timestamp("01 Apr 2016 13:30 +0000"), title = "Backtest Start Time", type = input.time)USE_ENDTIME = input(false,title="Define the ending period for backtests (If false, will test up to most recent candle)")backtest_timeframe_end = input(defval = timestamp("19 Mar 2021 19:30 +0000"), title = "Backtest End Time", type = input.time)TARGET_PROFIT_MODE = input(false,title="Exit when Risk:Reward met")REWARD_RATIO = input(3,title="Risk:[Reward] (i.e. 3) for exit")// Trailing stop loss {TSL_ON = input(true,title="Use trailing stop loss")var entry_price = float(0)ATR_multi_len = 26ATR_multi = input(2, "ATR multiplier for stop loss")ATR_buffer = atr(ATR_multi_len) * ATR_multi//plotchar(ATR_buffer, "ATR Buffer", "", location = location.top)risk_reward_buffer = (atr(ATR_multi_len) * ATR_multi) * REWARD_RATIOtake_profit_long = low > entry_price + risk_reward_buffertake_profit_short = low < entry_price - risk_reward_buffervar trailing_SL_buffer = float(0)var stop_loss_price = float(0)stop_loss_price := max(stop_loss_price, close - trailing_SL_buffer)// plot TSL linetrail_profit_line_color = color.greenif strategy.position_size == 0 or not TSL_ON trail_profit_line_color := color.black stop_loss_price := close - trailing_SL_bufferplot(stop_loss_price,color=trail_profit_line_color)// }// RSI {RSI_LOW = input(40,title="RSI entry")RSI_HIGH = input(70,title="RSI exit")rsi14 = rsi(close, 14)rsi10 = rsi(close, 10)// }if time >= backtest_timeframe_start and (time <= backtest_timeframe_end or not USE_ENDTIME) buy_condition = rsi14 <= RSI_LOW and rsi10 < rsi14 exit_condition = rsi14 >= RSI_HIGH and rsi10 > rsi14 //ENTRY: if buy_condition if strategy.position_size == 0 entry_price := close trailing_SL_buffer := ATR_buffer stop_loss_price := close - ATR_buffer msg = "entry" if strategy.position_size > 0 msg := "pyramiding" strategy.entry("Long",strategy.long, comment=msg) //EXIT: // Case (A) hits trailing stop if TSL_ON and strategy.position_size > 0 and close <= stop_loss_price if close > entry_price strategy.close("Long", comment="take profit [trailing]") else if close <= entry_price strategy.close("Long", comment="stop loss") // Case (B) take targeted profit relative to risk if strategy.position_size > 0 and TARGET_PROFIT_MODE if take_profit_long strategy.close("Long", comment="take profits [risk:reward]") // Case (C) if strategy.position_size > 0 and exit_condition if take_profit_long strategy.close("Long", comment="exit[rsi]")// Also included an additional script (Study script) - "RSI[14 + 10] Double Indicators"// The following script is a modification of the original RSI indicator built into TradingView// The reason that it is not included in the Strategy script is because the plotting scales are different.// // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// // © DojiEmoji// //@version=4// study(title="RSI[14 + 10] Double Indicators", shorttitle="RSI", format=format.price, precision=2, resolution="")// len1 = input(14, minval=1, title="RSI A Length")// src1 = input(close, "RSI A Source", type = input.source)// rsi1 = rsi(src1,len1)// plot(rsi1, "RSI", color=#ffffff)// len2 = input(10, minval=1, title="RSI B Length")// src2 = input(close, "RSI B Source", type = input.source)// rsi2 = rsi(src2,len2)// plot(rsi2, "RSI", color=#fb8c00)// band1 = hline(70, "Upper Band", color=#C0C0C0)// band0 = hline(30, "Lower Band", color=#C0C0C0)// fill(band1, band0, color=#9915FF, transp=90, title="Background")