TradingView
valpatrad
24 aug 2022 17:36

Intraday Background Time Ranges 

Apple Inc.NASDAQ

Beskrivning

This simple script was written for studying recurring intraday behaviours of financial instruments. With it, you can highlight up to 13 customizable time ranges on your chart, filling the corresponding background space with colors you prefer. You can then write a note for each range and it will be shown in the optional related table.

The experience shows that every financial instrument has its own personality. With this in mind, the script can be useful to study intraday charts with the purpose of discovering recurring behaviours of specific instruments over a certain time range and under specific circumstances (normal days, earnings days, days with catalysts, etc.) This can help the trader to deeply understand the instrument personality, and therefore also to decide whether to enter or exit the market if its behaviour meets or not his expectations.

Please note that this script only works on minute/hourly charts.

Versionsinformation

Minor fix: Now the table won't appear without any text.

Cleaned the code.

Versionsinformation

Update:

1) Shortened the short title, which now is "Time Ranges".

2) Removed the seconds time frame limitation.

3) Cleaned, simplified and improved the overall appearance of the code.

Versionsinformation

UPDATE:

Added 17 additional time ranges, bringing the total to 30.

Versionsinformation

UPDATE:

This new version includes the option to choose whether to project the colors ahead of time, allowing you to see them even before the price reaches the specified time.
In order to achieve this purpose, I had to modify the input mode for the time ranges.
Kommentarer
LM81trades
what a great indicator, thank you! is it possible to shade the timeranges a bit ahead of time - so we can see a timerange coming?
valpatrad
@LM81trades, I think this is not possible wiht Pine Script.
LM81trades
@valpatrad, thank you for your answer. other indicator can do it, so it should be possible.
valpatrad
@LM81trades, Can you give me some examples so I can better understand what you mean?
LM81trades
@valpatrad, yes, i can. look at the indicator "ICT Index Futures Vertical Lines" from ArdOfCrypto - it shows lunchtime beforehand..
valpatrad
@LM81trades, Thank you for bringing that indicator to my attention. It uses a very different logic because it relies on time zones. Based on the chosen time zone, it draws vertical lines with the vline() function and then colors the inner space using the linefill.new() function.

Instead, my indicator directly colors the background using the bgcolor() function. It would be impossible to adapt the existing code because the bgcolor() function does not allow coloring the chart in the future. To project them into the future, I should duplicate the time slots and move them ahead for a certain number of bars (offset), but this would result in inaccurate results for various reasons. For example, not all stocks have the same number of bars because not all of them are constantly traded. Some stocks, for instance, have no trading activity in the extended session. Furthermore, changing the chart mode from extended hours to regular hours would place the projected slot in a different position from the previously desired one.

I may consider rewriting the code using a different approach when I find some time. In that case, I will definitely let you know. Thank you for the suggestion anyway.
LM81trades
@valpatrad, thank you very much for checking! i am sure a lot of traders will appreciate your effort! thank you and have a great day!
valpatrad
@LM81trades, Hi, I have just updated the indicator including the new feature. I hope it will be useful to you. Have a nice day!
LM81trades
@valpatrad, hi there. wow, thank you so much!! this is awesome, i will test it right away. have a great time!
LM81trades
@valpatrad, hi there, i have tested couple days. after every candle it kinda reloads (the colors dissapear for a sec and come back). on very low timeframes it is very obvious. is it maybe because it goes quite long into the past? is it possible to limit it to maybe the last three days? it is an intraday indicator.. other from that i am very happy with the indicator and very thankful for your effort!! kind regards
Mer