Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Average Volume at Time of Day - Pine Script

Hi Im new at programming and would want to ask you guys for som help.

We watch volume to get an indication of momentum and participation. But how do you know if the volume is substantial or not? Especially if you are trading intrad day.

Say you are watching the market and it is 9:45 AM Eastern standard time. You see the market is moving up. You can see that the volume is higher than it was a period ago. Well, of course it was. That doesn’t tell us much because a period ago the markets were still closed so its expected. You could compare it to average volume which is what is done for daily charts. For intraday trading, it doesn’t help much to use a simple average of volume for comparison because the differences in volume between the regular session and the extended session can be quite big. Its like comparing apples to oranges.

So what we really want to do is compare the current volume in relation to the average volume at this specific time of day. We want to see if the current volume at 9:45 is higher, lower or the same as it normally is at 9:45. The “Average Volume at Time of Day” does just that.

The study does the following: for each bar on the chart, it calculates the average volume at that time based on the past X sessions – X is a parameter. It then plots the current volume and the average volume. The current volume are the bars in the foreground. The average volume for that period is the transparent rectangle in the background.

If the current volume is less than the average, the transparent color is painted red.

If the current volume is greater than the average, the transparent color is painted blue.

Does any one have an idea how to do this in pine script for trading view have a great day! =)