BTC Hashrate with smoothing
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Powerscooter
// Since IntoTheBlock only provides daily hashrate data, this chart might look chunky on lower timeframes, even with smoothing.

//@version=5
indicator("BTC Hashrate", overlay = true, scale = scale.none)
smoothing = input.string(title="Smoothing", defval="SMA", options=["SMA", "RMA", "EMA", "WMA"], group="Hashrate Settings")
ma_function(source, length) =>
	switch smoothing
		"RMA" => ta.rma(source, length)
		"SMA" => ta.sma(source, length)
		"EMA" => ta.ema(source, length)
		=> ta.wma(source, length)
SmoothLength = input(30, 'MA Length', group="Hashrate Settings")
Source = input.string(title="Data Source", defval="IntoTheBlock", options=["Glassnode", "IntoTheBlock"], group="Source Settings")
SourceE = switch Source
	"Glassnode" => "GLASSNODE:BTC_HASHRATE"
	"IntoTheBlock" => "INTOTHEBLOCK:BTC_HASHRATE"
HashRate = request.security(SourceE, "D", close)

plot(ma_function(HashRate, SmoothLength), "Hashrate", color=color.blue)