Indicator · Pine Script v4 · Own pane

Hash Ribbons

by DT021

This indicator plots daily Bitcoin hash-rate short and long simple moving averages in a separate pane.

View on GitHub

Repaints

GitHub stars1on the repository
Pine versionv4older, still runs
Lines of code90
Settings6inputs
LicenceGPL-3.0
Last update6 years ago10 Mar 2020

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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

90 lines of Pine Script v4 from third-party-pines/Hash Ribbons by capriole_charles copy.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

Hash Ribbons by capriole_charles copy.pine
//@version=4
study("Hash Ribbons",overlay= false)

// INPUTS
type = input('Ribbons',options=['Ribbons','Oscillator'],title="Plot Type")
len_s = input(30,"Hash Rate Short SMA (days).")
len_l = input(60,"Hash Rate Long SMA (days).")
signals = input(true, "Plot Signals")
s1020 = input(true,"Show first 10-20 SMA cross following Hash Bottom.")

plot_halvings = input(true,"Plot Halvings.")

// HASH RATE MA
// HR on TV only has "yesterday's" value --> use "lookahead_on" when running live (on current bar), to pull forward yesterdays data
live_HR_short = security("QUANDL:BCHAIN/HRATE", "D", sma(close,len_s),gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
live_HR_long = security("QUANDL:BCHAIN/HRATE", "D", sma(close,len_l),gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) 
hist_HR_short = security("QUANDL:BCHAIN/HRATE", "D", sma(close,len_s),gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off) 
hist_HR_long = security("QUANDL:BCHAIN/HRATE", "D", sma(close,len_l),gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off) 

// DAILY TIMEFRAME MGMT
is_newbar(res) =>
    t = time(res) // res calculated below \/
    change(t) != 0 ? true : false

// Check how many bars are in our upper (otf) timeframe
since_new_bar = barssince(is_newbar("D")) //1-360 for minutes, D = Daily, W = Weekly, M = Monthly
D_total_bars = int(na)
D_total_bars := since_new_bar == 0 ? since_new_bar[1] : D_total_bars[1] // calculates the total number of current time frame bars in the OTF 

// INDICATORS
HR_short = float(na)
HR_long = float(na)
HR_short := barstate.isrealtime ? (since_new_bar == D_total_bars ? hist_HR_short : HR_short[1]) : live_HR_short 
HR_long := barstate.isrealtime ? (since_new_bar == D_total_bars ? hist_HR_long : HR_long[1]) : live_HR_long 


capitulation = crossunder(HR_short,HR_long)
miner_capitulation = HR_short<HR_long 
recovering = HR_short > HR_short[1] and HR_short > HR_short[2] and HR_short > HR_short[3] and miner_capitulation
recovered= crossover(HR_short,HR_long)

// HASH BOTTOM + PA SIGNAL

s10 = sma(close,10)
s20 = sma(close,20)
cross = s10>s20
cross_down = crossunder(s10,s20)
buy = cross and barssince(recovered) < barssince(cross_down)

// OSCILLATOR
delta = HR_short-HR_long
diff = (delta/HR_short)*100
//risk = highest(diff,7) < 2 and lowest(diff,7) > 0

// PLOT - DEFAULT

p1=plot(type=='Ribbons'? HR_long : na, color = color.gray, linewidth = 2, style = plot.style_line,title='HR SMA Long') 
p2=plot(type=='Ribbons'? HR_short : na, color = (HR_short<HR_long? color.red : color.lime), linewidth = 2, style = plot.style_line,title = 'HR SMA Short')
fill(p1,p2,color=(HR_short<HR_long?color.red:na),transp=30)

// PLOT - OSCILLATOR

plot(type=='Oscillator' ? diff : na,style=plot.style_columns,color=(diff<0?color.red:color.blue),title='Oscillator')
//plotshape(risk,style=shape.circle,size = size.large, color = color.red,location=location.top)

// PLOT - SIGNALS

plotshape(signals ? capitulation :na,style=shape.circle,location=location.top,color=color.gray,size=size.normal,transp=50,text='Capitulation',textcolor=color.black,title='Capitulation')
plotshape(signals ? miner_capitulation : na,style=shape.circle,location=location.top,color=color.green,size=size.normal,transp=90,title='Miner Capitulation') 
plotshape(signals ? recovering : na,style=shape.circle,location=location.top,color=color.green,size=size.normal,transp=50,title='Recovering') 
plotshape(signals ? recovered : na,style=shape.circle,location=location.top,color=color.lime,size=size.normal,transp=0,textcolor=color.white,title='Recovered') 
plotshape(signals and s1020 ? buy and not(buy[1]): na,style=shape.circle,location=location.top,color=color.blue,size=size.normal,transp=0,text="Buy",textcolor=color.blue,title='Buy') 

// HALVINGS

halving_1 = timestamp(2012,11,28,0,0)
halving_2 = timestamp(2016,7,9,0,0)
halving_3 = timestamp(2020,4,30,0,0) // projected! https://www.bitcoinclock.com/
h1_range = time >= halving_1 - 3*(24*60*60*1000) and time <= halving_1 + 3*(24*60*60*1000) //adds 3 day either side for chart visibility
h2_range = time >= halving_2 - 3*(24*60*60*1000) and time <= halving_2 + 3*(24*60*60*1000) //adds 3 day either side for chart visibility
h3_range = time >= halving_3 - 3*(24*60*60*1000) and time <= halving_3 + 3*(24*60*60*1000) //adds 3 day either side for chart visibility
bgcolor(h1_range and plot_halvings? color.red : na, transp = 20)
bgcolor(h2_range and plot_halvings? color.red : na, transp = 20)
bgcolor(h3_range and plot_halvings? color.red : na, transp = 20)

//ALERTS

alertcondition(capitulation, title='Alert - Capitulation')
alertcondition(recovered, title='Alert - Recovered')
alertcondition(buy and not(buy[1]), title='Alert - Buy')

Overview

Hash Ribbons marks capitulation when the short average crosses under the long average, miner capitulation while it stays below, recovery while the short average rises, and a recovered crossover. Users can switch between filled ribbons and a percentage-difference oscillator, toggle those markers, show the first 10-day and 20-day price average cross after a hash bottom, and mark halvings. Lengths are adjustable. Daily data is requested with lookahead enabled, so historical and live values can differ.

Details

Published by

DT021 on GitHub

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Moving averages, Oscillators & momentum

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

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

SettingTypeDefaultVariable
Plot TypestringRibbonstype
Hash Rate Short SMA (days).int30len_s
Hash Rate Long SMA (days).int60len_l
Plot Signalsbooltruesignals
Show first 10-20 SMA cross following Hash Bottom.booltrues1020
Plot Halvings.booltrueplot_halvings
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

948 stars

The Derivative Oscillator calculates a double-exponentially smoothed Relative Strength Index (RSI) and subtracts its Simple Moving Average (SMA) to form the main oscillator line. A secondary signal line is plotted using an SMA of the main oscillator values. Th

Indicator v4 Oscillators & momentumMoving averages
Updated 10 days ago · GPL-3.0 GitHub repository of Derivative Oscillator

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

MACD

by Alorse
330 stars

This indicator calculates and plots the standard Moving Average Convergence Divergence oscillator in a separate pane. It computes the difference between a fast and slow moving average, derives a signal line through smoothing, and plots a histogram representing

Indicator v4 Oscillators & momentumMoving averages
Updated 2 months ago · None stated GitHub repository of MACD

MACD-V

by harryguiacorn
219 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers