• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing a Progressive Weekly Reference Line

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

    Drawing a Progressive Weekly Reference Line

    Dear Support,

    I need to draw a simple progressive horizontal line starting on the open (RTH) of the current market week and extending progressively into the close of the current market week and ends there. I do not want to use DateTime in Draw.Line() statement, if possible, since every Friday or Monday may not be a trading day.

    I could not find an example in Help section and looking for just the Draw.Line() code that would accomplish that. Any sample snippet or idea would be appreciated?

    Many Thanks

    #2
    Hello aligator,

    The line would like likely need to be updated on each new bar to extend to the current bar until the desired end date time is reached.

    Is the primary series using RTH as the Trading hours template?

    If so, are you wanting to draw a line from when Bars.IsFirstBarOfSession is true and the DayOfWeek is Sunday, up to the current bar until Friday?


    If not, are you adding a secondary series with a different trading hours template?

    Are you wanting to get the time of a session open from a SessionIterator?


    Is this an indicator?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      If I understand you right, you're saying the Y-value (aka price) of that
      line does not change for an entire week?

      Hmm, why not store the dates and Y-values in a file?

      The point is:
      Your 'drawing' indicator which draws the line can then consult this
      file, figure out which date to use, and then draw the line at the
      price found from this file.

      The task of updating this file, esp if maintained as a text file, is
      not that onerous if performed manually once at the start of each
      trading week.

      As a second phase, I'd recommend a separate indicator to update
      the file. Perhaps it could use a BarsRequest for minute data and
      wade through this data to get the RTH start time for the beginning
      of the week, then update the text file with this value.

      The point is:
      Separating them might get you started faster.

      I mean, write the first indicator to read from a file and get it
      up & running now so at least you have your weekly line drawn.

      Then work on the 2nd indicator to update this file based upon
      BarsRequest data, perhaps also merging the drawing code from
      the 1st indicator into this one.

      Just my 2˘.

      Comment


        #4
        This also might allow your drawing indicator to be pretty darn simple.

        I mean, it could probably just use a simple Plot to draw the line at the
        current known Y-value. [Oops, I mean it stores the current Y-value
        and the default Plot method draws your plot as a horizontal line, just
        like for any other plot where the plot value stays constant.]

        If you promise to manually update the date & Y-value at the start of
        each week, and if you promise to exit/restart NinjaTrader after you
        update this file, then the code to find the correct Y-value can run at
        State.DataLoaded, and everything works fine ... until next week,
        when you need to manually update the file again.

        The manual effort is small, and really doesn't sound all that bad.
        Last edited by bltdavid; 06-03-2020, 04:36 PM.

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello aligator,

          The line would like likely need to be updated on each new bar to extend to the current bar until the desired end date time is reached.

          Is the primary series using RTH as the Trading hours template?

          If so, are you wanting to draw a line from when Bars.IsFirstBarOfSession is true and the DayOfWeek is Sunday, up to the current bar until Friday?


          If not, are you adding a secondary series with a different trading hours template?

          Are you wanting to get the time of a session open from a SessionIterator?


          Is this an indicator?
          Thank you Chelsea.

          Simply, I am trying to use the PriorWeek's Close as a constant, and draw a line from the Open of the Monday RTH Session ending on the last bar of the current Friday RTH session close.

          I know I can do this similar to PriorWeekOHLC indicator, and I have already done it as a plot. However, when plotted as a solid line, the solid line unlike the Hash and Dash, does continue between session breaks like a zigzag(as is also the case with PriorWeekOHLC indicator).

          I want the prior week close plotted as a solid line separately (same as a Hash or Dash lines) for each week. That is why I want to use Draw.Line instead of a plot, if possible.

          Many thanks.




          Comment


            #6
            Originally posted by aligator View Post
            Simply, I am trying to use the PriorWeek's Close as a constant, and draw a line from the Open of the Monday RTH Session ending on the last bar of the current Friday RTH session close.

            I know I can do this similar to PriorWeekOHLC indicator, and I have already done it as a plot. However, when plotted as a solid line, the solid line unlike the Hash and Dash, does continue between session breaks like a zigzag(as is also the case with PriorWeekOHLC indicator).

            I want the prior week close plotted as a solid line separately (same as a Hash or Dash lines) for each week. That is why I want to use Draw.Line instead of a plot, if possible.
            I discovered a little known trick that worked well in NT7. I haven't
            tried it yet in NT8, but give it a shot, see if it works for your case.

            I believe if you call Reset on one plot value (say, the very first one of
            the new trading week) this 'invalid' value will cause the default Plot
            method to not connect the next plot value back to the previous one,
            since the previous one will be an unknown value.

            This should achieve the effect you're looking for. That is, I think
            you're wanting to remove the 'zig-zag' look created when the Plot
            method connects two adjacent (but different) plot values at your
            trading week boundary.



            Comment


              #7
              Hello aligator,

              Are you referring to the Prior Week Ohlc found on the Use App Share?
              https://ninjatraderecosystem.com/use...ior-week-ohlc/

              This indicator calculates the new week with:
              newWeek = Time[0].Date.AddDays(7 - (int)Time[0].DayOfWeek);

              This is taking the time of the current bar and using 7 minus the day of the week as a number (starting with sunday) to add the number of days left until the next week to the current date. (Setting the time the next week starts).
              When the current date is now beyond that date, we know the next week has started.

              This can be used for deciding when to use a new tag name for new line if you want to use Draw.Line().


              For the startTime parameter to Draw.Line use the Time of the current bar minus the day of week (which should give you the most recent sunday) and the Time of the current bar as the endTime parameter.

              Time[0].AddDays(-(int)Time[0].DayOfWeek)

              https://ninjatrader.com/support/help.../draw_line.htm


              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jayfutures23, Today, 07:06 AM
              0 responses
              1 view
              0 likes
              Last Post jayfutures23  
              Started by Spark68, Yesterday, 07:48 PM
              1 response
              17 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by Lotyok, Today, 01:08 AM
              4 responses
              25 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by Tri-Star, Yesterday, 07:28 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_PatrickG  
              Started by MojoJojo, Today, 05:59 AM
              0 responses
              4 views
              0 likes
              Last Post MojoJojo  
              Working...
              X