OPEN-SOURCE SCRIPT

Dblocs 4 Year BTC Cycle Guide

// Indicator Description:
// The "Dblocs 4 Year BTC Cycle Guide" indicator represents a fixed recurring profit-taking cycle that begins with each Bitcoin halving event.

// Functionality Explained:
// After every halving event, there has been a fixed number of weeks following that marked the area of highest profitability for taking profit.
// • 40 Weeks (Post-Halving) = Start of the optimal profit-taking zone.
// • 80 Weeks (Post-Halving) = "Last Call" for profit-taking before the bear market.
// • 135 Weeks (Post-Halving) = Optimal area to begin Dollar-Cost Averaging.

//version=5
indicator(title='Dblocs 4 Year BTC Cycle Guide', overlay=true)

// Function to check if it's after a halving based on months (weekly)
isAfterHalvingWeeks(y, m, d, months) =>
halvingDate = timestamp(y, m, d)
startDate = request.security(syminfo.tickerid, 'D', halvingDate + 1)
endDate = startDate + months * 30 * 24 * 60 * 60 * 300
time >= startDate and time <= endDate

// Function to check if it's after a halving based on months (monthly)
isAfterHalvingMonths(y, m, d, months) =>
halvingDate = timestamp(y, m, d)
startDate = request.security(syminfo.tickerid, 'M', halvingDate + 1)
endDate = startDate + months * 36 * 30 * 24 * 60 * 60 * 100
time >= startDate and time <= endDate

// Set the future halving date
halvingDate4th = timestamp(2024, 4, 19)

halvingdate = input(defval=true, title="Halving Date")
var WeeklyProfitSTART = input(true, title="(Weekly) Profit [START TP]")
var WeeklyProfitEND = input(true, title="(Weekly) Profit [END]")
var MonthlyProfitSTART = input(true, title="(Monthly) Profit [START TP]")
var MonthlyProfitEND = input(true, title="(Monthly) Profit [END]")
var DCAstart = input(true, title="DCA (Show)")
var ShowBackgroundColor = input(true, title="Show Background Color")

isDate(y, m, d) => timestamp(y, m, d) <= time and timestamp(y, m, d) > time[1]

// Check if it's a daily chart
isDaily = timeframe.isdaily

// Check if it's a weekly chart
isWeekly = timeframe.isweekly

// Check if it's a monthly chart
isMonthly = timeframe.ismonthly

// Weekly Plots & Calculations
profitStartOffsetWeekly = input.int(40, title="(Weekly) START Profit [Offset]", minval=-40)
profitEndOffsetWeekly = input.int(80, title="(Weekly) END Profit [Offset]", minval=0)
DCAstartOffsetWeekly = input.int(123, title="DCA Weekly [Offset]", minval=0)

// Monthly Plots & Calculations
profitStartOffsetMonthly = input.int(10, title="(Monthly) START Profit [Offset]", minval=-100)
profitEndOffsetMonthly = input.int(18, title="(Monthly) END Profit [Offset]", minval=0)
DCAstartOffsetMonthly = input.int(27, title="DCA Monthly [Offset]", minval=0)

// Use the same input for weekly
bgcolor(ShowBackgroundColor and isWeekly and (isAfterHalvingWeeks(2012, 11, 28, 5.5) or isAfterHalvingWeeks(2016, 7, 9, 5.5) or isAfterHalvingWeeks(2020, 5, 11, 5.5) or isAfterHalvingWeeks(2024, 4, 10, 6)) ? color.rgb(0, 255, 8, 90) : na, offset=+40)
bgcolor(ShowBackgroundColor and isWeekly and (isAfterHalvingWeeks(2012, 11, 28, 5.5) or isAfterHalvingWeeks(2016, 7, 9, 5.5) or isAfterHalvingWeeks(2020, 5, 11, 5.5) or isAfterHalvingWeeks(2024, 4, 10, 6)) ? color.rgb(0, 255, 8, 85) : na, offset=+47)
bgcolor(ShowBackgroundColor and isWeekly and (isAfterHalvingWeeks(2012, 11, 28, 5.5) or isAfterHalvingWeeks(2016, 7, 9, 5.5) or isAfterHalvingWeeks(2020, 5, 11, 5.5) or isAfterHalvingWeeks(2024, 4, 10, 6)) ? color.rgb(0, 255, 8, 80) : na, offset=+54)
bgcolor(ShowBackgroundColor and isWeekly and (isAfterHalvingWeeks(2012, 11, 28, 5.5) or isAfterHalvingWeeks(2016, 7, 9, 5.5) or isAfterHalvingWeeks(2020, 5, 11, 5.5) or isAfterHalvingWeeks(2024, 4, 10, 6)) ? color.rgb(0, 255, 8, 75) : na, offset=+61)
bgcolor(ShowBackgroundColor and isWeekly and (isAfterHalvingWeeks(2012, 11, 28, 5.5) or isAfterHalvingWeeks(2016, 7, 9, 5.5) or isAfterHalvingWeeks(2020, 5, 11, 5.5) or isAfterHalvingWeeks(2024, 4, 10, 6)) ? color.rgb(0, 255, 8, 60) : na, offset=+68)
bgcolor(ShowBackgroundColor and isWeekly and (isAfterHalvingWeeks(2012, 11, 28, 3.5) or isAfterHalvingWeeks(2016, 7, 9, 3.5) or isAfterHalvingWeeks(2020, 5, 11, 3.5) or isAfterHalvingWeeks(2024, 4, 10, 4)) ? color.rgb(0, 255, 8, 55) : na, offset=+75)

// Use the same input for monthly
bgcolor(ShowBackgroundColor and isMonthly and (isAfterHalvingMonths(2012, 11, 28, 0.25) or isAfterHalvingMonths(2016, 7, 9, 0.25) or isAfterHalvingMonths(2020, 5, 11, 0.25) or isAfterHalvingMonths(2024, 4, 10, 1)) ? color.rgb(0, 255, 8, 85) : na, offset=+11)
bgcolor(ShowBackgroundColor and isMonthly and (isAfterHalvingMonths(2012, 11, 28, 0.25) or isAfterHalvingMonths(2016, 7, 9, 0.25) or isAfterHalvingMonths(2020, 5, 11, 0.25) or isAfterHalvingMonths(2024, 4, 10, 1)) ? color.rgb(0, 255, 8, 80) : na, offset=+12)
bgcolor(ShowBackgroundColor and isMonthly and (isAfterHalvingMonths(2012, 11, 28, 0.25) or isAfterHalvingMonths(2016, 7, 9, 0.25) or isAfterHalvingMonths(2020, 5, 11, 0.25) or isAfterHalvingMonths(2024, 4, 10, 1)) ? color.rgb(0, 255, 8, 75) : na, offset=+13)
bgcolor(ShowBackgroundColor and isMonthly and (isAfterHalvingMonths(2012, 11, 28, 0.25) or isAfterHalvingMonths(2016, 7, 9, 0.25) or isAfterHalvingMonths(2020, 5, 11, 0.25) or isAfterHalvingMonths(2024, 4, 10, 1)) ? color.rgb(0, 255, 8, 65) : na, offset=+14)
bgcolor(ShowBackgroundColor and isMonthly and (isAfterHalvingMonths(2012, 11, 28, 0.25) or isAfterHalvingMonths(2016, 7, 9, 0.25) or isAfterHalvingMonths(2020, 5, 11, 0.25) or isAfterHalvingMonths(2024, 4, 10, 1)) ? color.rgb(0, 255, 8, 55) : na, offset=+15)
bgcolor(ShowBackgroundColor and isMonthly and (isAfterHalvingMonths(2012, 11, 28, 0.25) or isAfterHalvingMonths(2016, 7, 9, 0.25) or isAfterHalvingMonths(2020, 5, 11, 0.25) or isAfterHalvingMonths(2024, 4, 10, 1)) ? color.rgb(0, 255, 8, 45) : na, offset=+16)
bgcolor(ShowBackgroundColor and isMonthly and (isAfterHalvingMonths(2012, 11, 28, 0.25) or isAfterHalvingMonths(2016, 7, 9, 0.25) or isAfterHalvingMonths(2020, 5, 11, 0.25) or isAfterHalvingMonths(2024, 4, 10, 1)) ? color.rgb(0, 255, 8, 40) : na, offset=+17)

// Define a variable for label x-coordinate
labelX = isDaily ? bar_index + 280 : bar_index + 0

// Draw Halving function for daily
drawHalving(y, m, d, align, align2) =>
line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, color=color.rgb(255, 123, 0), style=line.style_dashed, width=3)
if (halvingdate)
label.new(bar_index, high, text='⛏\nHalving\n' + str.tostring(m) + '/' + str.tostring(d) + '/' + str.tostring(y) + '\n🟠', style=label.style_label_lower_right, textcolor=color.rgb(0, 0, 0), color=color.rgb(255, 136, 0, 5), textalign=text.align_center, yloc=yloc.abovebar, size=size.normal)
if isWeekly
label.new(WeeklyProfitSTART ? labelX + profitStartOffsetWeekly : na, na, text='Profit\nSTART\n🟢\n⛏\n40ʷ ᵃᵍᵒ', style=label.style_label_lower_right, textcolor=color.rgb(0, 0, 0), color=color.rgb(17, 255, 0), textalign=text.align_center, yloc=yloc.abovebar, size=size.normal)
label.new(WeeklyProfitEND ? labelX + profitEndOffsetWeekly : na, na, text='Profit\nEND\n🔴\n⛏\n80ʷ ᵃᵍᵒ', style=label.style_label_lower_left, textcolor=color.rgb(0, 0, 0), color=color.rgb(255, 0, 0), textalign=text.align_center, yloc=yloc.abovebar, size=size.normal)
label.new(DCAstart ? labelX + DCAstartOffsetWeekly : na, na, text='→\nDCA\n🟡\n⛏\n135ʷ ᵃᵍᵒ', style=label.style_label_up, textcolor=color.rgb(0, 0, 0), color=color.rgb(226, 246, 0, 25), textalign=text.align_center, yloc=yloc.belowbar, size=size.normal)
line.new(WeeklyProfitSTART ? labelX + profitStartOffsetWeekly : na, low, WeeklyProfitSTART ? labelX + profitStartOffsetWeekly : na, high, xloc.bar_index, extend.both, color=color.rgb(0, 255, 8), style=line.style_dotted, width=2)
line.new(WeeklyProfitEND ? labelX + profitEndOffsetWeekly : na, low, WeeklyProfitEND ? labelX + profitEndOffsetWeekly : na, high, xloc.bar_index, extend.both, color=color.rgb(255, 0, 0), style=line.style_dotted, width=2)
label.new(WeeklyProfitSTART ? labelX + profitStartOffsetWeekly : na, high, style=label.style_cross, yloc=yloc.abovebar, color=color.rgb(40, 255, 0), size=size.small)
label.new(WeeklyProfitEND ? labelX + profitEndOffsetWeekly : na, high, style=label.style_cross, yloc=yloc.abovebar, color=color.rgb(40, 255, 0), size=size.small)
label.new(DCAstart ? labelX + DCAstartOffsetWeekly + 0 : na, high, style=label.style_circle, yloc=yloc.belowbar, color=color.rgb(251, 226, 0), size=size.tiny)
label.new(DCAstart ? labelX + DCAstartOffsetWeekly + 12 : na, high, style=label.style_circle, yloc=yloc.belowbar, color=color.rgb(203, 249, 0, 35), size=size.tiny)
label.new(DCAstart ? labelX + DCAstartOffsetWeekly + 24 : na, high, style=label.style_circle, yloc=yloc.belowbar, color=color.rgb(170, 255, 59, 46), size=size.tiny)
label.new(DCAstart ? labelX + DCAstartOffsetWeekly + 36 : na, high, style=label.style_circle, yloc=yloc.belowbar, color=color.rgb(115, 255, 0, 58), size=size.tiny)
label.new(DCAstart ? labelX + DCAstartOffsetWeekly + 48 : na, high, style=label.style_circle, yloc=yloc.belowbar, color=color.rgb(38, 255, 0, 58), size=size.tiny)

if isMonthly
label.new(MonthlyProfitSTART ? labelX + profitStartOffsetMonthly : na, na, text='Profit\nSTART\n🟢\n⛏\n40ʷ ᵃᵍᵒ', style=label.style_label_lower_right, textcolor=color.rgb(0, 0, 0), color=color.rgb(17, 255, 0), textalign=text.align_center, yloc=yloc.abovebar, size=size.normal)
label.new(MonthlyProfitEND ? labelX + profitEndOffsetMonthly : na, na, text='Profit\nEND\n🔴\n⛏\n80ʷ ᵃᵍᵒ', style=label.style_label_lower_left, textcolor=color.rgb(0, 0, 0), color=color.rgb(255, 0, 0), textalign=text.align_center, yloc=yloc.abovebar, size=size.normal)
... (35 lines left)
Candlestick analysisChart patternsCycles

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור