Announcement

Collapse
No announcement yet.

Drawing Vertical Line at the Daily or Weekly or Monthly Open on an Intraday Chart

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Drawing Vertical Line at the Daily or Weekly or Monthly Open on an Intraday Chart

    Hi,
    Is it possible to draw a vertical line on the first intraday Candle which identifies the Daily or Weekly or Monthly Open?
    Thanks
    Paul

  • #2
    Paul
    With the daily and monthly intervals check for BARSTATE_NEWBAR and for the day or month [ie day(0) or month(0)] to be different from [IOW not equal to] the previous value of the day or month [ie (day(-1) or month(-1)]. At that time you draw your vertical line. Search the forum as there are already examples on how to do this since the topic has been covered before
    For the weekly since there is no week function [like day() or month()] you need to create your own. Run a search for getDOW* and you should find an example of how to do this. Once you have the function create a series of it using efsInternal() and then apply a logic similar to the the one explained above for daily or monthly with the only difference being that you would check for the value of the DOW to be less than the previous value (since Monday is less than Friday). At that time you draw your vertical line
    Alex


    Originally posted by TURLIES View Post
    Hi,
    Is it possible to draw a vertical line on the first intraday Candle which identifies the Daily or Weekly or Monthly Open?
    Thanks
    Paul

    Comment


    • #3
      Thanks Alex

      Comment


      • #4
        Paul
        You are welcome
        Alex


        Originally posted by TURLIES View Post
        Thanks Alex

        Comment


        • #5
          Hi Alex,
          After reading a previous post of yours, I created a simple study to do this. The issue I am having is that the line is being drawn on my NQ #F chart at 00:00 GMT, instead of 22:00 GMT for the actual open. Any ideas?
          Thanks,
          Paul


          function main(){

          if(getBarStateInterval("W")==BARSTATE_NEWBAR){ //at every first tick of a weekly bar

          // WEEKLY OPEN

          drawTextRelative(0, 0, " W ", Color.cyan, Color.white, Text.FRAME | Text.BOLD | Text.RELATIVETOBOTTOM | Text.CENTER, null, 10, "Text");
          drawLineRelative(0, 0, 0, Infinity, PS_SOLID, 2, Color.cyan, "Line");

          }


          return;

          }

          Comment


          • #6
            Paul
            The reason that is happening is because external intervals are synchronized by date and time and the daily (and higher) intervals are time stamped as 00:00 hence the line will be located at the first bar that has a similar date and time.
            As I suggested in my prior reply search for getDOW* and you should find a function that determines the day of the week. Once you have that add it to your formula in which you create a conditional statement that checks for a new bar and for the day of the week to be less than 5 (which is Friday thereby looking for any day of the week starting from Sunday) and for a global variable to be equal to false. At that time you draw your line and reset the global variable to true.
            Then you create another condition which checks for the same global variable to be true and for the day of the week to be equal to 5 (again Friday) at which point you reset your global variable to false thereby preparing it for the conditional statement explained above thus repeating the cycle
            Once you do the above the vertical line will be drawn on the first bar of Sunday (which is when the Monday trade date begins) or first following trading day thereafter (if Monday is a holiday)
            Alex


            Originally posted by TURLIES View Post
            Hi Alex,
            After reading a previous post of yours, I created a simple study to do this. The issue I am having is that the line is being drawn on my NQ #F chart at 00:00 GMT, instead of 22:00 GMT for the actual open. Any ideas?
            Thanks,
            Paul


            function main(){

            if(getBarStateInterval("W")==BARSTATE_NEWBAR){ //at every first tick of a weekly bar

            // WEEKLY OPEN

            drawTextRelative(0, 0, " W ", Color.cyan, Color.white, Text.FRAME | Text.BOLD | Text.RELATIVETOBOTTOM | Text.CENTER, null, 10, "Text");
            drawLineRelative(0, 0, 0, Infinity, PS_SOLID, 2, Color.cyan, "Line");

            }


            return;

            }

            Comment


            • #7
              That's great. Thanks Alex.

              Comment


              • #8
                Paul
                You are welcome
                Alex


                Originally posted by TURLIES View Post
                That's great. Thanks Alex.

                Comment

                Working...
                X