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

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 Rapine Heihei, 04-23-2024, 07:51 PM
        2 responses
        30 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        942 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        9 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        4 views
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        28 views
        0 likes
        Last Post wzgy0920  
        Working...
        X