Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
How to obtain the day of year and the week of year in EasyLanguage
I need help to have a way to get the number of day of the year (1-365) and also the number of week of the year (1-53) in EasyLanguage, because as I can see it seems the language doesn’t come with these 2 built-in functions and I can’t find examples about it.
About the day of year, for now the closest I’ve gotten is to work at the same time with the month of year and the day of month `Month(Date) = n1 And DayOfMonth(Date) = n2` that is a two step process that I think this could be done in a more efficient and direct way, like maybe defining a starting date of the year and adding the n days needed, to in this way to go to a specific day of the year, but I haven’t found how to cover the situation to have the year not specified, i.e. in a general way that works for any year, where for example maybe you only specify a Jan fixed date (YYYY0101) as starting point and then adding n days to that date, but this working in a general way for any year.
Anyways, this is just an idea because those who are more familiar with EasyLanguage maybe have other ways to get this and other alternatives are more than welcome.
And about the week of the year I haven’t found much information, but as with the day of the year calculation, the idea is to get this in an efficient way that keeps the logic running as smooth as possible
Thank you in advance for the help!
Can you help answer these questions from other members on NexusFi?
But about the Day, I can see it skips the weekends/holidays, what maybe was the purpose, but, would it be possible to take into account every calendar day of the year including weekends/holidays, where for example yesterday Sunday Feb 12, 2023 was the day 43, and today is the day 44, ...
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,033 since Dec 2013
Thanks Given: 4,359
Thanks Received: 10,172
I had assumed (incorrectly) you wanted a trading day count not a calendar day count.
Using Calendar Day makes calculating week easier. Haven't tested this but this should work
Var: Day(0), Week(0);
If intportion(DATE/10000) <> intportion(DATE[1]/10000) then Day = 0;
if DATE <> DATE[1] then Day = Day + DATE - DATE[1];
Week = intportion(Day/7) + 1;
The following 2 users say Thank You to SMCJB for this post:
Using Calendar Day makes calculating week easier. Haven't tested this but this should work
Var: Day(0), Week(0);
If intportion(DATE/10000) <> intportion(DATE[1]/10000) then Day = 0;
if DATE <> DATE[1] then Day = Day + DATE - DATE[1];
Week = intportion(Day/7) + 1;
Thank you @SMCJB, but I made some tests and I see this other solution doesn't calculate the calendar day or the week number.
For example, for today Feb 15, it shows Day = 8985 and Week = 1284, so maybe it could be some consideration not applied to the calculation.