' ---------------------------
' WeekNumber - ISO Compatible
' ---------------------------
' ISO says to find the first Thursday of each year and then back
' off to that Week's Monday to determine the first date in a year
' when Week #1 occurs.
'
' This code uses that same logic to find the first Thursday and then
' goes back to identify that week's Monday.
'
' When the first date of a year doesn't fall into Week #1, it says
' to use information from the previous year to determine if the first
' date of the year falls into Week #52 or Week #53. This code also
' uses that logic to fill that requirement.
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Variables: WeekNumber TYPE: INTEGER
Variables: Day_Offset TYPE: INTEGER
Variables: DayName TYPE: STRING
Day_Offset = 0
WeekNumber = WeekNumberISO(Instrument.Date[Day_Offset])
' ``````````````````````````````````````````````````````````
' ``````````````````````````````````````````````````````````
' Print the Results to the Output.CSV File
' ``````````````````````````````````````````````````````````
If Instrument.CurrentBar = 1 Then
' Send Results to the PRINT LOG
Print "Date: ", _
" DOW-Name ", _
" Week_# "
EndIf
DayName = DayOfWeekName( DayOfWeek(Instrument.Date[Day_Offset]))
' Send Results to the PRINT LOG
Print Instrument.Date[Day_Offset], _
DayName, _
WeekNumber
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|