Pine Script v4 · Strategy
BTC Sentiment analysis RSI 2xEMA
A Pine Script v4 strategy built on Change, RSI (48) and EMA (longs, 10). 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. 8 settings; defaults include RSI length 48, EMA input 10 and From Day 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 BTC Sentiment analysis RSI 2xEMA repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did BTC Sentiment analysis RSI 2xEMA 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 code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can BTC Sentiment analysis RSI 2xEMA be converted to Pine Script v5?
- Not tested
- The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
- Does BTC Sentiment analysis RSI 2xEMA use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does BTC Sentiment analysis RSI 2xEMA run in Zeal Terminal?
- Yes
- It compiles in 11 ms and runs 1,000 bars in 42 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- HLine
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs BITFINEX:BTCUSDLONGS D data, not available: not a Binance spot market Needs BITFINEX:BTCUSDSHORTS D data, not available: not a Binance spot market 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 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
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
1 setting has no label
In the settings dialog ema_input (line 12) shows 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.
-
Note
Uses an argument v6 removed
when = on line 34, 35. 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 change → ta.change, security → request.security, rsi → ta.rsi, ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder.
- 2 strategy calls use the when = argument (line 34, 35). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 3: //@version=4 → //@version=5
- Line 5: change → ta.change
- Line 5: security → request.security
- Line 6: change → ta.change
- Line 6: security → request.security
- Line 8: rsi → ta.rsi
12 more edits
- Line 8: security → request.security
- Line 9: rsi → ta.rsi
- Line 9: security → request.security
- Line 13: ema → ta.ema
- Line 14: ema → ta.ema
- Line 15: ema → ta.ema
- Line 16: ema → ta.ema
- Line 17: ema → ta.ema
- Line 17: ema → ta.ema
- Line 34: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
- Line 34: crossover → ta.crossover
- Line 35: crossunder → ta.crossunder
⋯// © exlux99-//@version=4+//@version=5strategy("BTC Sentiment analysis RSI",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 )-longs = change(security("BITFINEX:BTCUSDLONGS", timeframe.period, close))+longs = ta.change(request.security("BITFINEX:BTCUSDLONGS", timeframe.period, close))-shorts = change(security("BITFINEX:BTCUSDSHORTS", timeframe.period, close))+shorts = ta.change(request.security("BITFINEX:BTCUSDSHORTS", timeframe.period, close))l = input(48, title="RSI length")-rsilong = rsi(security("BITFINEX:BTCUSDLONGS", timeframe.period, close), l)+rsilong = ta.rsi(request.security("BITFINEX:BTCUSDLONGS", timeframe.period, close), l)-rsishort = rsi(security("BITFINEX:BTCUSDSHORTS", timeframe.period, close), l)+rsishort = ta.rsi(request.security("BITFINEX:BTCUSDSHORTS", timeframe.period, close), l)plot(rsilong, color=color.green, style=plot.style_line)⋯ema_input=input(10)-ema_1 = ema(longs, ema_input)+ema_1 = ta.ema(longs, ema_input)-ema_2 = ema(shorts, ema_input)+ema_2 = ta.ema(shorts, ema_input)-ema_3 = ema(longs, ema_input)+ema_3 = ta.ema(longs, ema_input)-ema_4 = ema(shorts, ema_input)+ema_4 = ta.ema(shorts, ema_input)-bcolor = longs > ema(longs, ema_input) and shorts > ema(shorts, ema_input) ? color.yellow : +bcolor = longs > ta.ema(longs, ema_input) and shorts > ta.ema(shorts, ema_input) ? color.yellow : longs > ema_1 and shorts < ema_2 ? color.lime : ⋯if(time_cond)- strategy.entry("long",1,when=crossover(rsilong,rsishort) and (longs > ema_1 and shorts < ema_2))+ strategy.entry("long",strategy.long,when=ta.crossover(rsilong,rsishort) and (longs > ema_1 and shorts < ema_2))- strategy.close('long',when=crossunder(rsilong,rsishort) and (longs < ema_3 and shorts > ema_4))+ strategy.close('long',when=ta.crossunder(rsilong,rsishort) and (longs < ema_3 and shorts > ema_4)) //strategy.entry('short',0,when=crossunder(rsilong,rsishort) and longs < ema_3 and shorts > ema_4)Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 7: input() → input.int()
- Line 12: input() → input.int()
- Line 22: input() → input.int()
- Line 23: input() → input.int()
- Line 24: input() → input.int()
- Line 27: input() → input.int()
4 more edits
- Line 28: input() → input.int()
- Line 29: input() → input.int()
- Line 34: when = ta.crossover(rsilong,rsishort) and (longs > ema_1 and shorts < ema_2) → if block
- Line 35: when = ta.crossunder(rsilong,rsishort) and (longs < ema_3 and shorts > ema_4) → if block
⋯shorts = ta.change(request.security("BITFINEX:BTCUSDSHORTS", timeframe.period, close))-l = input(48, title="RSI length")+l = input.int(48, title="RSI length")rsilong = ta.rsi(request.security("BITFINEX:BTCUSDLONGS", timeframe.period, close), l)⋯plot(rsishort, color=color.red, style=plot.style_line)-ema_input=input(10)+ema_input=input.int(10)ema_1 = ta.ema(longs, ema_input)⋯hline(0)-fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)+fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-fromYear = input(defval = 2000, title = "From Year", minval = 1970)+fromYear = input.int(defval = 2000, title = "From Year", minval = 1970) //monday and session // To Date Inputs-toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)+toDay = input.int(defval = 31, title = "To Day", minval = 1, maxval = 31)-toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)+toMonth = input.int(defval = 12, title = "To Month", minval = 1, maxval = 12)-toYear = input(defval = 2021, title = "To Year", minval = 1970)+toYear = input.int(defval = 2021, title = "To Year", minval = 1970)startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)⋯if(time_cond)- strategy.entry("long",strategy.long,when=ta.crossover(rsilong,rsishort) and (longs > ema_1 and shorts < ema_2))+ if ta.crossover(rsilong,rsishort) and (longs > ema_1 and shorts < ema_2)+ strategy.entry("long",strategy.long)- strategy.close('long',when=ta.crossunder(rsilong,rsishort) and (longs < ema_3 and shorts > ema_4))+ if ta.crossunder(rsilong,rsishort) and (longs < ema_3 and shorts > ema_4)+ strategy.close('long') //strategy.entry('short',0,when=crossunder(rsilong,rsishort) and longs < ema_3 and shorts > ema_4)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.
⋯// © exlux99-//@version=5+//@version=6strategy("BTC Sentiment analysis RSI",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 |
|---|---|---|---|
| RSI length | 48 | int | rsilong rsishort |
| EMA input (no label in the script) | 10 | int | ema_1 ema_2 ema_3 ema_4 bcolor |
| From Day | 1 | int · min 1 · max 31 | startDate |
| From Month | 1 | int · min 1 · max 12 | startDate |
| From Year | 2000 | int · min 1970 | startDate |
| To Day | 31 | int · min 1 · max 31 | finishDate |
| To Month | 12 | int · min 1 · max 12 | finishDate |
| To Year | 2021 | int · min 1970 | finishDate |
What it calculates
- Change (
change,ta.changein v5)security("BITFINEX:BTCUSDLONGS", timeframe.period, close)longs · line 5 - Change (
change,ta.changein v5)security("BITFINEX:BTCUSDSHORTS", timeframe.period, close)shorts · line 6 - RSI (
rsi,ta.rsiin v5)security("BITFINEX:BTCUSDLONGS", timeframe.period, close), RSI length (48)rsilong · line 8 - RSI (
rsi,ta.rsiin v5)security("BITFINEX:BTCUSDSHORTS", timeframe.period, close), RSI length (48)rsishort · line 9 - EMA (
ema,ta.emain v5)longs, EMA input (10)ema_1 · line 13 - EMA (
ema,ta.emain v5)shorts, EMA input (10)ema_2 · line 14 - EMA (
ema,ta.emain v5)longs, EMA input (10)ema_3 · line 15 - EMA (
ema,ta.emain v5)shorts, EMA input (10)ema_4 · line 16
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 | crossover(rsilong,rsishort) and (longs > ema_1 and shorts < ema_2) | On | 34 |
| Close long | crossunder(rsilong,rsishort) and (longs < ema_3 and shorts > ema_4) | On | 35 |
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 data4 security call(s), none with lookahead on.
- 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
Not run on other markets: the script requests BITFINEX:BTCUSDLONGS D, BITFINEX:BTCUSDSHORTS D, and that data is not available here (not a Binance spot market; not a Binance spot market). 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 |
|---|---|---|---|---|---|
| BTC Sentiment analysis RSI 2xEMA this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| RSI Cross [xaurr] by livetrend | rsi ema | v4 strategy | +24.4% | 53 | 35.3% |
| Bitpanda Coinrule Template by joshuajcoop01 | rsi ema | v5 strategy | −2.8% | 4 | 4.6% |
| RSI with Slow and Fast MA Crossing Strategy (by Coinrule) by Coinrule | rsi ema | v5 strategy | −2.8% | 4 | 4.6% |
| RSI of VWAP by mohanee | rsi ema | v4 strategy | No trades on this market | ||
| EMA SCALPEUR + RSi - SHORT by YukalMoon | rsi ema | 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 42 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 34) so the engine trades the way the script says. 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/// © exlux99//@version=4strategy("BTC Sentiment analysis RSI",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 )longs = change(security("BITFINEX:BTCUSDLONGS", timeframe.period, close))shorts = change(security("BITFINEX:BTCUSDSHORTS", timeframe.period, close))l = input(48, title="RSI length")rsilong = rsi(security("BITFINEX:BTCUSDLONGS", timeframe.period, close), l)rsishort = rsi(security("BITFINEX:BTCUSDSHORTS", timeframe.period, close), l)plot(rsilong, color=color.green, style=plot.style_line)plot(rsishort, color=color.red, style=plot.style_line)ema_input=input(10)ema_1 = ema(longs, ema_input)ema_2 = ema(shorts, ema_input)ema_3 = ema(longs, ema_input)ema_4 = ema(shorts, ema_input)bcolor = longs > ema(longs, ema_input) and shorts > ema(shorts, ema_input) ? color.yellow : longs > ema_1 and shorts < ema_2 ? color.lime : longs < ema_3 and shorts > ema_4 ? color.red : color.grayplot(0, color=bcolor, style=plot.style_cross, linewidth=3)hline(0)fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)fromYear = input(defval = 2000, title = "From Year", minval = 1970) //monday and session // To Date InputstoDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)toYear = input(defval = 2021, title = "To Year", minval = 1970)startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear, toMonth, toDay, 00, 00)time_cond = time >= startDate and time <= finishDate if(time_cond) strategy.entry("long",1,when=crossover(rsilong,rsishort) and (longs > ema_1 and shorts < ema_2)) strategy.close('long',when=crossunder(rsilong,rsishort) and (longs < ema_3 and shorts > ema_4)) //strategy.entry('short',0,when=crossunder(rsilong,rsishort) and longs < ema_3 and shorts > ema_4)