Bitcoin Pi Cycle

Bitcoin commonly trades to levels derived from π. Pi Cycle Top 🟥 + Pi Cycle Bottom 🟩 print when two moving averages cross one another, which when divided produce 3.14. Ω marks the breakout of each bull cycle. Golden bands mark the bottom of each cycle, and guide mid-cycle price action.
 avatar
ozzylivin
c_cpp
7 months ago
4.2 kB
8
Indexable
Never
// This source code is open source


//@version=4
study(title='Pi Cycle π Bitcoin', shorttitle='Pi Cycle π', overlay=true)

// Set Text color
color textColor = input(color.new(#DDDDDD, 0), "Text Color", type = input.color)

// Set Daily Interval
resolution = input('D', type=input.string, title="Time interval")

// Display Options
is_show_ma = input(true, type=input.bool, title="Show Blue α Bands ?")
is_show_bands = input(true, type=input.bool, title="Show Golden α Bands ?")
is_show_pima = input(true, type=input.bool, title="Show Pi Cycle MA ?")

// --------------------
// Pi Cycle π Top
// --------------------
top_ma_short = input(116, minval=1, title="Pi Cycle 🔴 116 MA")
top_ma_long = input(365, minval=1, title="Top Band")
ma_long_t = security(syminfo.tickerid, resolution, sma(close, top_ma_long)*2)
ma_short_t = security(syminfo.tickerid, resolution, sma(close, top_ma_short))
src_t = security(syminfo.tickerid, resolution, close)


bColor = color.rgb(220, 220, 220)

if (close < ma_short_t)
    bColor := color.aqua

barcolor(bColor, offset = 0)

// α Bands
plot(is_show_bands?ma_long_t/0.314:na, color=color.rgb(76, 175, 168, 95))
plot(is_show_bands?ma_long_t/0.5:na, color=color.rgb(76, 175, 168, 90))
plot(is_show_bands?ma_long_t/0.618:na, color=color.rgb(76, 175, 168, 85))
plot(is_show_bands?ma_long_t/0.786:na, color=color.rgb(76, 175, 168, 80))

// Golden Corridor
gc1 = plot(is_show_bands?ma_long_t/2:na, color=color.rgb(253, 204, 68, 50), title="Upper Golden Band")
gc2 = plot(is_show_bands?ma_long_t/1.5:na, color=color.rgb(253, 204, 68, 50), title="Lower Golden Band")

// fill between Golden Corridor
fill(gc1, gc2, color = color.rgb(253, 204, 68, 95), title="Fill the Golden Corridor")

// Top Band
b1 = plot(is_show_ma?ma_long_t:na, color=color.aqua, title="Upper Blue Band") 

// Pi Cycle 116 MA
p1 = plot(is_show_pima?ma_short_t:na, color=color.rgb(253, 68, 68), title="Pi Cycle 116 MA") 
var topma_short_label = label.new(x = bar_index, y = top_ma_short, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.red, text = "Pi")
label.set_xy(topma_short_label, x = bar_index, y = ma_short_t)

// Plot Pi Cycle π Top Arrow
PiCycleTop = crossunder(ma_long_t, ma_short_t) ? src_t + (src_t/100 * 10) : na
plotshape(PiCycleTop, style=shape.triangledown,size=size.small, text="π", color=color.red, textcolor=textColor, location=location.abovebar, title="π Cycle Top")


// --------------------
// Pi Cycle π Bottom
// --------------------
len_ma_long = input(470, minval=1, title="Lower Blue Band")
len_ma_short = input(150, minval=1, title="Golden Fibonacci MA")

ma_long = security(syminfo.tickerid, resolution, sma(close, len_ma_long)*0.745)
ma_short = security(syminfo.tickerid, resolution, ema(close, len_ma_short))
src = security(syminfo.tickerid, resolution, close)

// Bottom Band
b2 = plot(is_show_ma?ma_long:na, color=color.aqua, title="Bottom Band") 

// Golden Fibonacci MA
p2 = plot(is_show_pima?ma_short:na, color=color.rgb(253, 68, 68, 90), title="Golden Fibonacci MA") 

// fill between Top & Bottom Band
fill(b1, b2, color = color.rgb(57, 224, 253, 95), title="Fill Top & Bottom Band")

// fill between Pi Cycle 111 MA and Golden Fibonacci MA
fill(p1, p2, color = color.rgb(253, 68, 68, 80), title="Fill Pi Cycle 111 MA")

// α Bands
plot(is_show_bands?ma_long/1.314:na, color=color.rgb(241, 151, 15, 90))
plot(is_show_bands?ma_long/1.5:na, color=color.rgb(241, 151, 15, 75))
plot(is_show_bands?ma_long/1.618:na, color=color.rgb(241, 151, 15, 50))
plot(is_show_bands?ma_long/1.786:na, color=color.rgb(253, 204, 68), linewidth=2, title="Golden Band")

// Plot Pi Cycle π Bottom Arrow
// PiCycleBottom = crossover(low, ma_long/1.786) ? src + (src/100 * 10) : na
PiCycleBottom = crossover(ma_long, ma_short) ? src + (src/100 * 10) : na
plotshape(PiCycleBottom, style=shape.triangleup,size=size.small, text="π", color=color.green, textcolor=textColor, location=location.belowbar, title="π Cycle Bottom")

// Plot Breakout
BreakOut = crossover(ma_short, ma_long) ? src + (src/100 * 10) : na
plotshape(BreakOut, style=shape.triangleup,size=size.small, text="Ω", color=color.aqua, textcolor=textColor, location=location.belowbar, title="Ω Breakout")


Leave a Comment