This is likely an easy problem, but I'm still on the learning curve here....I'm looking for a way to be able to choose the background colors based on the interval selection. So if the user chooses an intraday charting (tick, 1-min, 5-min, 15-min, etc) the background would have the color selection to show pre-market (Blackish-red), post-market (Blackish Blue), and regular market hours, (Regular Black) and then alternatively if the user chooses a different time frame that is daily scale or longer (ie. weekely, monthly, etc.) then the background coloring selection would be something different (ie. alternating black and grey to differentiate each month). Can someone lead me down the correct path on how to do this? For reference below are the representations of what I want each to look like, but just trying to be able to toggle within a single chart if I choose either an "intra-day" or "extra-day" time frame. Thanks again in advance AFL community!!
In that formula, the code shows how to use an area chart to "color" a zone defined by a specific time interval.
Once you have grasped the logic, you should add some conditionals to apply different rules/colors based on the current selected Interval() - Search the forum for "interval switch" to find some examples.
I also suggest reading this past thread and, in particular, post #13 by @Tomasz.
Thank you @fxshrat, Yes, your code worked well and I've implemented it as such, but since I have two different chart styles (one is for intra-day and the other is for daily charts and longer time frames (as shown in the two pics provided), I currently have it set up where each one is in it's own separate tab at the bottom. What I'm trying to do is basically use only one representation, but be able to either automatically switch based on the time frame selected (if intra-day then it provides the pre, post and regular market hours) as per pic 1, and then if it's daily or longer time frames it shows as the second pic. Other option would be to use a toggle switch in the parameter window so that the user can choose at their discretion.
I'll test out the interval code as you and @beppe have mentioned.
Ah yes....this works! Thanks to both of you for your guidance. Since I tested your original code in portions, I forgot to implement the second part. My bad!!