OPEN-SOURCE SCRIPT

Weekly/Daily/Hourly/Minutes Colored Background Intervals

This is my "Weekly/Daily/Hourly/Minutes Colored Background Intervals" assistant. I wouldn't describe it as an indicator, it just exhibits coloration of referenced periods of time with bgcolor() in Pine. With the arrival of 2021, I pondered the necessity of needing a visualization pre-2021 to visually recognize periodicity of market movements by the week, day, hour, or an adjustable period of minutes. While this script is simply generic, I hope you may find useful in your endeavors as a member on TradingView.

Explaining the script's usage, the "Minutes" input can be adjusted from anywhere between 5-55 minutes for only intraday. This can be modified to accommodate 90 minutes (1.5hrs) or any other minutes period desirable by tweaking certain numbers up to 1440. Minutes and Hourly backgrounds are disabled by default for most daily traders. Changing the input() code to `true` will provide them on by default when the script loads, if you choose that route. Each time periods background color is enable/disable capable. All of the colors are easily adjustable to any combination you can ponder for your visual acuity with the color swatch provided by input(type=input.color). The coloring can be "swapped" by input() depending on how you wish to start and end the day visually. I thought this would come in handy. The weekly background can have different starting points, whether it be Sunday, Monday, or any other day such as Friday for example.

The entire script's contents isn't intended for complete re-use as is for publicly published scripts. It's more along the lines of code that could be used to personally modify indicators you have, depending on the time frames you may actually be trading on. The code is basically modular, so you can use bits and pieces of it in your personally modified Pine Editor scripts that you wish to customize for yourself. I will say that the isXxx() functions are completely reusable in any script without any need for author permission inquiries from me, as easy as copy and paste. Those may come in handy for many folks. If you find them useful in certain circumstances, use isXxx() functions as you please. Day of the week detection by functions will have applications beyond my current intended use for them.

Of notable mention, this is a miniature lesson by example of how the new input(type=input.color) may be used. I'm also using `var` inside functions to aid in computational efficiency of the script runtime. The colors are permanently stored at the very beginning of the scripts operation inside the function and just reused from that point onward. Its a rare use case, but well suited for this scripts intention. Once again I have demonstrated the "Power of Pine" for developers of any experience level to learn from via code elegance.

When available time provides itself, I will consider your inquiries, thoughts, and concepts presented below in the comments section, should you have any questions or comments regarding this indicator. When my indicators achieve more prevalent use by TV members , I may implement more ideas when they present themselves as worthy additions. Have a profitable future everyone!
backgroundbackground-colorbgcolorDaily ChartshourlyperiodsTrend AnalysisWeekly Charts

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer