# How to overcome this issue (weeks contains holidays )

#### huab

##### New member
I wanted to make a study that divides last week volume to the week before.. (timeaggreg: week), the problem is that there are 9-10 weeks during the year with 4 trading days, so the comparision will not be logical..
Can I use calculations from getweek(), getdayofweek() -and any other data- functions, or there are an easier/straightforwad ways?

Solution
I think, the most straight forward approach would be to compare the sum of the preceding 5 days to the sum of the 5 days before those:
sum(volume(aggregation daily), 5) / sum(volume(aggregation daily)[6], 5)
or something like that.

it's a trade off (no puns intended) that will give you a rolling week rather than a static Monday to Friday week, but it may prove useful.

The most important questions, and the one that @Joshua tried to get at is what will you do with your statistics when you find a four-day week. That is a question whose answer will determine the approach you take in mitigating the bad data that a 4 day week presents in analysis.

If you could determine the four day weeks, would you simply multiply the volume...
Can I use calculations from getweek(), getdayofweek() -and any other data- functions, or there are an easier/straightforwad ways?
Can you use them... to do what? What is your plan on how to handle the four day weeks?

I think, the most straight forward approach would be to compare the sum of the preceding 5 days to the sum of the 5 days before those:
sum(volume(aggregation daily), 5) / sum(volume(aggregation daily)[6], 5)
or something like that.

it's a trade off (no puns intended) that will give you a rolling week rather than a static Monday to Friday week, but it may prove useful.

The most important questions, and the one that @Joshua tried to get at is what will you do with your statistics when you find a four-day week. That is a question whose answer will determine the approach you take in mitigating the bad data that a 4 day week presents in analysis.

If you could determine the four day weeks, would you simply multiply the volume for the week by 1.25?

Another random thought is this:
You might be able to use some magic to determine if a given number of days in the past is the same number of trading days in the past. Just a thought.

Perhaps it's helpful, perhaps not so much so
-mashume

Can you use them... to do what? What is your plan on how to handle the four day weeks?
I imagined if i used getyear(), then we know from the calendar holidays fall in which weeks, getweek() returns the week number from 1 to 53, then make a condition if getweek equal 3, for example, and that was 4 trading days, then multiply the volume by 1.25 ..
I mistakenly typed getdayofweek() as I was thinking of other way but it required multi aggregation times (then, for example if the volume of the symbol in day 4 of the week is nan then multiple the previous one by 1.25 ..
(I'm still a beginner)

Yes, if you actually wanted to check the calendar and do it manually like that, it could work. A better question might be, what type of chart are you planning to use this indicator on, and-or how do you intend on displaying the data? The most effective method I could think of would require the script to be used on a daily chart, which would reconstruct the weeks from that perspective, and automatically detect the four day weeks.

ChartBubble issue Questions 4
Scanner Issue... Questions 4
Clarification on Multi-Timeframe Issue Questions 1
Date Range Cloud Drawing issue Questions 4
Percent Change Watchlist Column Issue Questions 7

87k+ Posts
404 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?