US Presidential Elections
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © NoaTrader

//@version=5
indicator("US Presidential Elections",overlay = true,max_labels_count = 500)
var show_elec = input.bool(true,"Show Election Lables")
var show_inag = input.bool(true,"Show Inauguration Labels")

is_election_year = (year - 1800) %4 == 0
is_election_month = month == 11 or (month == 12 and month[1] == 10)
is_election_week = weekofyear == 45
is_election_dow = dayofweek == 2

// if month == 1 or month == 2 or month == 3
    // label.new(bar_index,close,str.tostring(month),color = color.white)

election_daily_cond = timeframe.isdaily and is_election_year and is_election_week and is_election_dow 
election_weekly_cond = timeframe.isweekly and is_election_year and is_election_week
election_monthly_cond = timeframe.ismonthly and is_election_year and is_election_month and not is_election_month[1]
if election_daily_cond or election_weekly_cond or election_monthly_cond
    if show_elec
        label.new(bar_index,high*1.02,"Election",textcolor = color.white)

is_inauguration_year = (year - 1800) %4 == 1
is_inauguration_month = month == 1
is_inauguration_week = weekofyear == 3
is_inauguration_dow = dayofmonth == 20

inauguration_daily_cond = timeframe.isdaily and is_inauguration_year and is_inauguration_month and is_inauguration_dow
inauguration_weekly_cond = timeframe.isweekly and is_inauguration_year and is_inauguration_week
inauguration_monthly_cond = timeframe.ismonthly and is_inauguration_year and is_inauguration_month //and not is_election_month[1]
if inauguration_daily_cond or inauguration_weekly_cond// or inauguration_monthly_cond
    if show_inag
        label.new(bar_index,high*1.02,"Inauguration",color=color.orange)