Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Drawing a Progressive Weekly Reference Line

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

  • joselube001
    replied
    Originally posted by aligator View Post

    Thanks. I did kind of get it to work at least for my objective, which was to plot the Expected Move projected for the current week based on the last week's close. Black is the last week close and red and green are the expected move for the current week.

    As you see I had to use Hash instead of solid line to avoid a solid continuous line. Also, there is an indicator, CurrentDayOHL.cs, on NT that will essentially do the same (can make H&L transparent and show only the Open). However the use of session iterator is the key.

    Cheers!
    Hi!

    Your indicator works nicely!! almost all months is touching the upper or lower line. Excellent!

    Leave a comment:


  • aligator
    replied
    Originally posted by joselube001 View Post
    Hi aligator,

    If you still need help with this I have posted some useful base code and an indicator base to do this.
    Here is the post:
    https://ninjatrader.com/support/foru...into-draw-line
    Look till the end of the post.

    I was searching exactly the same as you!!

    Click image for larger version  Name:	fetch?id=1180965&d=1638984003.png Views:	0 Size:	48.8 KB ID:	1180970
    Thanks. I did kind of get it to work at least for my objective, which was to plot the Expected Move projected for the current week based on the last week's close. Black is the last week close and red and green are the expected move for the current week.

    As you see I had to use Hash instead of solid line to avoid a solid continuous line. Also, there is an indicator, CurrentDayOHL.cs, on NT that will essentially do the same (can make H&L transparent and show only the Open). However the use of session iterator is the key.

    Cheers!
    Attached Files
    Last edited by aligator; 12-09-2021, 12:24 AM.

    Leave a comment:


  • joselube001
    replied
    Hi aligator,

    If you still need help with this I have posted some useful base code and an indicator base to do this.
    Here is the post:
    https://ninjatrader.com/support/foru...into-draw-line
    Look till the end of the post.

    I was searching exactly the same as you!!

    Click image for larger version

Name:	fetch?id=1180965&d=1638984003.png
Views:	108
Size:	48.8 KB
ID:	1180970

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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


    Leave a comment:


  • bltdavid
    replied
    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.



    Leave a comment:


  • aligator
    replied
    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.




    Leave a comment:


  • bltdavid
    replied
    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.

    Leave a comment:


  • bltdavid
    replied
    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˘.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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?

    Leave a comment:


  • aligator
    started a topic Drawing a Progressive Weekly Reference Line

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by bmaltz, Yesterday, 07:15 PM
2 responses
13 views
0 likes
Last Post bmaltz
by bmaltz
 
Started by iceman600, Yesterday, 01:51 PM
4 responses
25 views
0 likes
Last Post iceman600  
Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
55 responses
13,424 views
3 likes
Last Post grimes12  
Started by Mindset, Yesterday, 05:43 AM
4 responses
36 views
0 likes
Last Post Mindset
by Mindset
 
Started by brenton, Today, 08:31 PM
0 responses
15 views
0 likes
Last Post brenton
by brenton
 
Working...
X