Weekday counter with fixed dates  [SOLVED]

Questions about MultiCharts and user contributed studies.
Jonny473
Posts: 68
Joined: 04 Apr 2016
Has thanked: 5 times
Been thanked: 1 time

Weekday counter with fixed dates

Postby Jonny473 » 13 Aug 2018

I am struggling to do the following:

I have certain past and future dates for certain holdiays which are floating. Therefore I had write down every single date. I am struggling with the counter if those dates fall into weekends:

I am defining a variable first to hold the date:

Code: Select all

var:datexyz(0);
datexyz=dayofweek(1100407)


If (datexyz= 6) or (datexyz=0) then
weekendCount = weekendCount + 1;

datexyz= datexyz - weekendCount;
Unfortunately this does not work; I alos tried with the ELdate function instead. Also not working.
I just want to add 1 to the original date so the strategy can start working.

Can somebody help?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Weekday counter with fixed dates

Postby TJ » 13 Aug 2018

What is the expected behavior?

See Post #4
viewtopic.php?f=16&t=11713

Jonny473
Posts: 68
Joined: 04 Apr 2016
Has thanked: 5 times
Been thanked: 1 time

Re: Weekday counter with fixed dates  [SOLVED]

Postby Jonny473 » 15 Aug 2018

Hi TJ,

the expected behaviour is that whenever the date (juliantodate) is not a weekday (6 or 0) then 1 is added to to the value so it becomes a weekday.

Basically I got it working out with the following function:

Code: Select all

Inputs:
myDate(NumericSimple);


If DayOfWeek(myDate) = Sunday or DayOfWeek(myDate) = Saturday
then
NotWeekend = false
else
NotWeekend = true;
So whenever this is true one can add/subtract 1 to the date.


Return to “MultiCharts”