Wednesday, October 1, 2025

Bitcoin Power Law code in TradingView

I can't remember who posted this for the Bitcoin Power Law code. Anyway, here is the code to be used with TradingView:

***************************************************************************

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

//@version=6

indicator("Power Law", overlay=true)


// Days X-Axis Value

start = time == timestamp(2010, 7, 18, 0, 0)

days = request.security('INDEX:BTCUSD', 'D', ta.barssince(start))

offset = 561 // days between 2009/1/3 and "start"

d = days + offset


a = input(-17.668, 'Power Law Intercept',group = "Power Law Settings")

b = input(5.926, 'Power Law Slope',group = "Power Law Settings")


price_power_law_0 = math.pow(10, a + b * math.log10(d))

price_power_law_1 = math.pow(10, a + b * math.log10(d+1*365))

price_power_law_2 = math.pow(10, a + b * math.log10(d+2*365))

price_power_law_3 = math.pow(10, a + b * math.log10(d+3*365))

price_power_law_4 = math.pow(10, a + b * math.log10(d+4*365))

price_power_law_5 = math.pow(10, a + b * math.log10(d+5*365))


p0 = plot(price_power_law_0, color=#ffffffaa, title='Power Law',linewidth = 1)

p1 = plot(price_power_law_1, title='Power Law 1',linewidth = 1, color=bar_index % 2 == 0 ? #ffffffaa : #00000000)

p2 = plot(price_power_law_2, title='Power Law 2',linewidth = 1, color=bar_index % 2 == 0 ? #ffffffaa : #00000000)

p3 = plot(price_power_law_3, title='Power Law 3',linewidth = 1, color=bar_index % 2 == 0 ? #ffffffaa : #00000000)

p4 = plot(price_power_law_4, title='Power Law 4',linewidth = 1, color=bar_index % 2 == 0 ? #ffffffaa : #00000000)

p5 = plot(price_power_law_5, title='Power Law 5',linewidth = 1, color=bar_index % 2 == 0 ? #ffffffaa : #00000000)


***************************************************************************

No comments:

Post a Comment

Thank you!

Highly recommend you check out this website by @w_s_bitcoin (Wicked)

Highly recommend you check out this website showing all sorts of Bitcoin visualisations by  https://x.com/w_s_bitcoin  (Wicked / @w_s_wicked...