Solar Seasons
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jamiedubauskas

//@version=5
indicator(title = "Seasons", shorttitle = "Seasons", overlay = true)

show_summer = input.bool(title = "Summer", defval = true)
show_spring = input.bool(title = "Spring", defval = true)
show_winter = input.bool(title = "Winter", defval = true)
show_fall = input.bool(title = "Fall", defval = true)
current_hemisphere = input.string(title = "Current Hemisphere", options = ["Northern", "Southern"], defval = "Northern")
month = (dayofmonth < 21 and month > 1) ? month-1 : month

is_summer = current_hemisphere == "Northern" ? month >= 6 and month <= 8 : month == 12 or month == 1 or month == 2
is_spring = current_hemisphere == "Northern" ? month >= 3 and month <= 5 : month >= 9 and month <= 11
is_fall = current_hemisphere == "Northern" ? month >= 9 and month <= 11 : month >= 3 and month <= 5
is_winter = current_hemisphere == "Northern" ? month == 12 or month == 1 or month == 2 : month >= 6 and month <= 8

// plotting the instances of summmer
bgcolor(is_summer and show_summer ? color.new(color.yellow, 75) : na)
bgcolor(is_spring and show_spring ? color.new(color.blue, 75) : na)
bgcolor(is_fall and show_fall ? color.new(color.orange, 75) : na)
bgcolor(is_winter and show_winter ? color.new(color.white, 75) : na)

