Announcement

Collapse
No announcement yet.

Day of Week function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Day of Week function

    Greetings all, I have had a good measure of success coding indicators to analyze stochastic cycles and floor traders' pivots in multiple time frames but I have had an issue finding a 'Day of Week' function in the current EFS function library, all I can find is day() or getDay() and they are both day of month functions and neither are useful for coding for end of week conditions.

    Does anyone have any suggestions?

    Regards
    Andrew

  • #2
    Re: Day of Week function

    Andrew
    Use getValue("time") to create a date object of the bar time and then use the getDay() method of the Date Object to retrieve the day of the week eg
    PHP Code:
    var  barDate getValue("time");
    var 
    dayOfWeek barDate.getDay(); 
    dayOfWeek will be a value from 0 to 6 where 0 is equal to Sunday, 1 is Monday, etc.
    Alex


    Originally posted by FrodoNZ
    Greetings all, I have had a good measure of success coding indicators to analyze stochastic cycles and floor traders' pivots in multiple time frames but I have had an issue finding a 'Day of Week' function in the current EFS function library, all I can find is day() or getDay() and they are both day of month functions and neither are useful for coding for end of week conditions.

    Does anyone have any suggestions?

    Regards
    Andrew

    Comment


    • #3
      Well, I will answer my own question, it's simply a case of coding it as:
      day(0,inv("W")) by specifying the week interval instead of omitting an interval it sets the context to weekly bars. I guess barstate would also work.

      At least putting it out there, although a form of thinking out loud helped me to dig deeper.

      Thanks for listening / reading....

      Andrew

      Comment


      • #4
        Thanks Alexis, I didn't see your post when posting an update, I did not know that, that's another option to use.

        Regards
        Andrew

        Comment


        • #5
          Thanks again Alexis, your method works.

          The code I posted actually returns the day of month at the beginning of the current week and that was coincident with the day count on Wednesday.

          Regards
          Andrew

          Comment


          • #6
            Andrew
            You are welcome and thank you for confirming as I did actually wonder if I had misread your original question
            Alex


            Originally posted by FrodoNZ
            Thanks again Alexis, your method works.

            The code I posted actually returns the day of month at the beginning of the current week and that was coincident with the day count on Wednesday.

            Regards
            Andrew

            Comment

            Working...
            X