Strategy · Pine Script v4 · Own pane

BTC Sentiment analysis RSI

by hasnocool· code credited to exlux99

This strategy plots the RSI of Bitfinex Bitcoin long and short interest in a separate pane and colors a zero line from changes in those series versus short exponential moving averages.

View on GitHub

GitHub stars106on the repository
Pine versionv4older, still runs
Lines of code37
Settings8inputs
LicenceGPL-3.0
Last update2 years ago18 Sep 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

37 lines of Pine Script v4 from BTC Sentiment analysis RSI 2xEMA.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

BTC Sentiment analysis RSI 2xEMA.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © exlux99
//@version=4
strategy("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.gray
plot(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 Inputs
toDay = 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)
Expand (45 lines)

Overview

BTC Sentiment analysis RSI opens a long when the long-interest RSI crosses above the short-interest RSI and long interest is above its average while short interest is below its average. It closes that long on the opposite cross with the opposite average relationship. RSI length, average length, and a date window are adjustable. There is no stop loss, and the short entry is disabled.

Details

Published by

hasnocool on GitHub

Code credit

exlux99, as written in the script's header

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI lengthint48l
ema_inputint10ema_input
From Dayint1fromDay
From Monthint1fromMonth
From Yearint2000fromYear
To Dayint31toDay
To Monthint12toMonth
To Yearint2021toYear
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

330 stars

MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points. It filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure tra

Strategy v4 Oscillators & momentumDivergence Repaints
Updated 2 months ago · None stated GitHub repository of MACD + Divergences [Alorse]

Q-Trend + KVO Strategy

by TradersPost
218 stars

This strategy combines the ATR-banded Q-Trend indicator with the Klinger Volume Oscillator (KVO) to execute confluence trades. It enters long when a Q-Trend buy trigger aligns with a positive KVO value and a bullish candle confirmation, taking short trades und

Strategy v6 TrendVolume
Updated 3 months ago · None stated GitHub repository of Q-Trend + KVO Strategy

MACD Crossover (tutorial)

by pineforge-4pass
193 stars

This strategy calculates the Moving Average Convergence Divergence indicator and plots the MACD line, signal line, and histogram in a separate pane. It enters long positions when the MACD line crosses above the signal line and enters short positions when it cr

Strategy v6 Oscillators & momentumMoving averages
Updated today · Apache-2.0 GitHub repository of MACD Crossover (tutorial)
114 stars

This strategy estimates price behavior using ordinary least squares regression between higher-timeframe data and a generated dataset, smoothed by a Karobein oscillator. It enters long positions when the oscillator turns upward and short positions when it turns

Strategy v4 Oscillators & momentumAI / machine learning Repaints
65 stars

This strategy calculates a 20-period Relative Strength Index (RSI) and generates entry orders based on crossovers and crossunders of the 50 level. When RSI crosses above 50, it places a long stop entry at the current high price with a custom alert message. Whe

Strategy v4 Oscillators & momentum
Updated 4 days ago · GPL-3.0 GitHub repository of Strategy Using Alert Message

BTC Futures MACD

by iamrichardD
57 stars

This strategy plots a MACD oscillator in a separate pane and trades Bitcoin futures from zero-line and signal-line crosses. Optional early momentum signals, a volume filter, and a trend moving-average filter can confirm entries. It sizes positions as fixed con

Strategy v6 Oscillators & momentumMoving averages Repaints
Updated 1 year ago · Apache-2.0 GitHub repository of BTC Futures MACD

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers