• 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

Dynamic plots?

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

    Dynamic plots?

    Question:

    On Ninja 7 Is there a way to dynamically add plots? I don't think so but thought I would ask the experts.

    Scenario:

    I want the user to specify the number of calculated lines to be displayed.

    Summary:

    The only thing I could think of is to add the maximum number of plots in the initialize section and then only set values for the number requested by the user.


    Cheers,

    #2
    Hello ct,

    Thank you for the post.

    As far as I am aware it would not be possible to dynamically add plots in this way. You can try using a for loop to create the plots in Initialize, however, using runtime logic in Intialize is generally not suggested. This is something you can test to observe what the result is and see if that meets your needs. A problem with this approach is that there is no way to apply looping logic to create public properties which would matter if you are trying to make this exposed as a signal as well. You can assign plots using the Values collection, however, there is no name associated to know which index is which line.

    Do the lines need to specifically to be plotted or would simply rendering them on the chart work for this use case? You can add Drawing objects dynamically like this and basically as many of them as you wanted. You could additionally render this using the Plot override.

    Your proposed solution would also work, setting many plots and using transparent or not setting a value unless used would also work.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello ct,

      Thank you for the post.

      As far as I am aware it would not be possible to dynamically add plots in this way. You can try using a for loop to create the plots in Initialize, however, using runtime logic in Intialize is generally not suggested. This is something you can test to observe what the result is and see if that meets your needs. A problem with this approach is that there is no way to apply looping logic to create public properties which would matter if you are trying to make this exposed as a signal as well. You can assign plots using the Values collection, however, there is no name associated to know which index is which line.

      Do the lines need to specifically to be plotted or would simply rendering them on the chart work for this use case? You can add Drawing objects dynamically like this and basically as many of them as you wanted. You could additionally render this using the Plot override.

      Your proposed solution would also work, setting many plots and using transparent or not setting a value unless used would also work.

      I look forward to being of further assistance.
      Jesse

      My favorite Ninja support person, thanks for the reply. The "for" loop is what I used. The drawing objects work but they bog Ninja down in a big way after you add a bunch (and I do). I use the values but I have to offset it by the number of any prior plots before the "for loop". I have used the plot number rather than name for years so that's easy for me. I go all the way back to Ninja 2.3 and not sure if plot name was supported then,

      Cheers
      New Zealand

      Comment


        #4
        Hello CT,

        If drawing objects work for the purpose but are slow, you could use the Plot override to reduce the toll on the PC and accomplish the same task. This is essentially what the Pivots indicator already does so you can likely just take the rendering code out of that script for this use case.

        If you take a look at the pivots indicator code starting at line 456, this loops through the scripts series and renders them on the chart. You can do this as well or a similar process, rendering only the visible data for performance. This prevents the need for drawing objects which have memory and cpu use associated with them but allows you to render directly to the chart.


        I look forward to being of further assistance.


        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ryanmercado, Today, 10:04 AM
        0 responses
        3 views
        0 likes
        Last Post ryanmercado  
        Started by uiwislth, Yesterday, 11:25 PM
        0 responses
        5 views
        0 likes
        Last Post uiwislth  
        Started by Steve L, Yesterday, 10:04 PM
        0 responses
        3 views
        0 likes
        Last Post Steve L
        by Steve L
         
        Started by marianfed, Yesterday, 09:47 PM
        0 responses
        5 views
        0 likes
        Last Post marianfed  
        Started by hir04068, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post hir04068  
        Working...
        X