UnknownUnicorn468659

Week of the Year indicator

Simple time indicator showing weeks of the year. Acts to help you define the greater perspective of time on your charts. You can overlay it on the entire chart or use it small and consolidated like I prefer it.

Easiest to configure colors in the script itself and then leave transparency values untouched:
q1w1 = the first week of the first quarter of the year (1st week of january, indicating a new year)
q1= 1-13
q2= 14-26
q3= 27-39
q4=40-53

Hope this helps you, like it helps me.
Best regards,

IMPORTANT NOTE:
Because the scripts asks for the week of the year it doesn't exactly indicate the first day of the quarter of the year. Instead it indicates the year like this: 52 / 4 = 13 W p/Q. Or in other words: 13 weeks per quarter of the year (roughly). Every 5.6 years there's a 53rd week, which will not cause any trouble as long as TV allows the use of the 53rd week, which I think it does.
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?
study(title="Week of the Year", shorttitle="Week of the Year", overlay=true)
q1w1 = #ffffff
q1 = #0099ff
q2 = #33ccff
q3 = #ff9900
q4 = #fc1687
bgColor =(weekofyear == 1) ? color(q1w1, 0):
    (weekofyear == 2) ? color(q1, 7) :
    (weekofyear == 3) ? color(q1, 14) :
    (weekofyear == 4) ? color(q1, 21) :
    (weekofyear == 5) ? color(q1, 28) :
    (weekofyear == 6) ? color(q1, 35) :
    (weekofyear == 7) ? color(q1, 42) :
    (weekofyear == 8) ? color(q1, 49) :
    (weekofyear == 9) ? color(q1, 56) :
    (weekofyear == 10) ? color(q1, 63) :
    (weekofyear == 11) ? color(q1, 70) :
    (weekofyear == 12) ? color(q1, 77) :
    (weekofyear == 13) ? color(q1, 84) :
    (weekofyear == 14) ? color(q2, 0) :
    (weekofyear == 15) ? color(q2, 7) :
    (weekofyear == 16) ? color(q2, 14) :
    (weekofyear == 17) ? color(q2, 21) :
    (weekofyear == 18) ? color(q2, 28) :
    (weekofyear == 19) ? color(q2, 35) :
    (weekofyear == 20) ? color(q2, 42) :
    (weekofyear == 21) ? color(q2, 49) :
    (weekofyear == 22) ? color(q2, 56) :
    (weekofyear == 23) ? color(q2, 63) :
    (weekofyear == 24) ? color(q2, 70) :
    (weekofyear == 25) ? color(q2, 77) :
    (weekofyear == 26) ? color(q2, 84) :
    (weekofyear == 27) ? color(q3, 0) :
    (weekofyear == 28) ? color(q3, 7) :
    (weekofyear == 29) ? color(q3, 14) :
    (weekofyear == 30) ? color(q3, 21) :
    (weekofyear == 31) ? color(q3, 28) :
    (weekofyear == 32) ? color(q3, 35) :
    (weekofyear == 33) ? color(q3, 42) :
    (weekofyear == 34) ? color(q3, 49) :
    (weekofyear == 35) ? color(q3, 56) :
    (weekofyear == 36) ? color(q3, 63) :
    (weekofyear == 37) ? color(q3, 70) :
    (weekofyear == 38) ? color(q3, 77) :
    (weekofyear == 39) ? color(q3, 84) :
    (weekofyear == 40) ? color(q4, 0) :
    (weekofyear == 41) ? color(q4, 7) :
    (weekofyear == 42) ? color(q4, 14) :
    (weekofyear == 43) ? color(q4, 21) :
    (weekofyear == 44) ? color(q4, 28) :
    (weekofyear == 45) ? color(q4, 35) :
    (weekofyear == 46) ? color(q4, 42) :
    (weekofyear == 47) ? color(q4, 49) :
    (weekofyear == 48) ? color(q4, 56) :
    (weekofyear == 49) ? color(q4, 63) :
    (weekofyear == 50) ? color(q4, 70) :
    (weekofyear == 51) ? color(q4, 77) :
    (weekofyear == 52) ? color(q4, 84) :
    (weekofyear == 53) ? color(q4, 91) :
    color(black, 0)
bgcolor(color=bgColor)