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

Best way to go about drawing a candle to the right of the last bar?

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

    Best way to go about drawing a candle to the right of the last bar?

    Howdy.

    So I am looking to draw a Candle to the right of the last price bar based on some other numbers.

    What I am wondering is what would be the best way to go about doing this? I imagine I can just do it by drawing lines/rectangles with a negative offset [-1]. I have used a negative offset before and seems to work ok.

    But is there a way to use custom plotting to accomplish this? Does anyone have a simple example of something they have done in the past?

    Another question, although not as essential, would be what would it take to make this something that was 'scrollable?' For example, if it was based on the last 100 bars, if I scrolled back in the chart, it would be based on the the right most bar visible on the chart, and the 99 bars to the left of that. Kind of like the volume histograms that will adjust if you move the chart to the left. Again, this isn't as important but figured I'd inquire about it.

    An general example of what this would look like is attached.
    Attached Files

    #2
    Hello forrestang, and thank you for your question.

    All of our DataSeries objects which reference bars are convenience objects. This is to say

    • Every BarsAgo index will always be referenced to the most recent bar, with 0 being the current bar
    • CurrentBar will always refer to the total number of bars available

    When you do things like use negative indices to refer to the future for positioning, you are working in a context where BarsAgo and CurrentBar have meaning, and thus a context where the above are both true. This is "all or nothing"; if you step outside of this - for instance, you'd like to index 0 to the most recent bar showing on the screen - then you can not use NinjaScript DataSeries, and you can't make CurrentBar mean anything else for a NinjaScript DataSeries. You are of course free to extend DataSeries with a subclass that does math on incoming indices based on what is showing on the screen. This is, however, not supported by the documentation.


    If you would like to step outside of both the documentation, and the BarsAgo context, you can use the Plot() method in NinjaTrader 7. While this is not documented in NinjaTrader 7, the similar OnRender() method in NinjaTrader 8 is fully documented and supported. That documentation is here.





    I would highly recommend creating a documented and supported version of the indicator you would like to create in NinjaTrader 8, then relying on IntelliSense, internet searches, and the Code Breaking Changes page here, to backport this to NinjaTrader 7 . The Plot and OnRender methods are very similar, and many screen drawing methods and members maintain their names and functionality between NinjaTrader 7 and 8.





    We are happy to help with any questions that come up along the way.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      There seems to be a problem with the "DrawRectangle" function.

      I'm sure I've used this before w/o a problem. It will allow me to draw a rectangle with a negative index, but not a normal positive index.

      I have noted some users having a similiar problem here, although I do not know if they ever got that issue resolved?


      I was using the NT7 .30 build, just upgraded to .31, and the problem still seems to persist.

      Just a note.

      Comment


        #4
        Thank you for this additional information. I believe I misunderstood what you meant by custom plotting.

        The documentation for DrawRectangle is here in NT7 and NT8





        Would it be possible for us to see how you are attempting to use DrawRectangle ?
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by gbourque, Today, 06:39 AM
        0 responses
        2 views
        0 likes
        Last Post gbourque  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by benmarkal, Yesterday, 12:52 PM
        3 responses
        23 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by helpwanted, Today, 03:06 AM
        1 response
        20 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        12 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Working...
        X