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

Dynamically adding Plots/Values

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

    Dynamically adding Plots/Values

    I am fetching values from a URL to overlay on my chart. There will always be 2 but up to (N) number of values to display.

    In other words, I will be fetching a dictionary that has an unknown number of keys in it, I want to display all of them, but it might have 5 today and then 4 tomorrow when the new data is fetched. Is there a way I can dynamically add/remove Values/Plots? Any examples you can point me to?

    At the moment I think this is not possible and I'll have to draw my own custom lines... which I am not super familiar with. Any alternative approaches appreciated.


    #2
    Hello NickyD,

    Thanks for your question.

    Plots can be added as late as State.Configure, so depending on what you are accessing, you could dynamically add plots there. We should note that some properties based on loaded data or user input may not be available in State.Configure (I.E. Bars, Instrument, User Defined Inputs) so that may be a road block for what you are trying to add dynamically.

    AddPlot() - https://ninjatrader.com/support/help...8/?addplot.htm

    If what you are doping requires User Defined Inputs and/or data loaded, State.DataLoaded would need to be used and you will need to use custom rendering to draw your plots. Plots can be drawn with Geometry. I have attached an example that can demonstrate. You should be familiar with SharpDX rendering, so I recommend following our SampleCustomRender example indicator that comes with NinjaTrader and the documentation below to get acquainted.



    We look forward to assisting.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      That code sample looks like I can adapt it for this purpose, thanks. I guess I will have dive into SharpDX finally, I've been avoiding it for a few years.

      Comment


        #4
        Originally posted by NinjaTrader_Jim View Post
        Hello NickyD,

        Thanks for your question.

        Plots can be added as late as State.Configure, so depending on what you are accessing, you could dynamically add plots there. We should note that some properties based on loaded data or user input may not be available in State.Configure (I.E. Bars, Instrument, User Defined Inputs) so that may be a road block for what you are trying to add dynamically.

        AddPlot() - https://ninjatrader.com/support/help...8/?addplot.htm

        If what you are doping requires User Defined Inputs and/or data loaded, State.DataLoaded would need to be used and you will need to use custom rendering to draw your plots. Plots can be drawn with Geometry. I have attached an example that can demonstrate. You should be familiar with SharpDX rendering, so I recommend following our SampleCustomRender example indicator that comes with NinjaTrader and the documentation below to get acquainted.

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

        We look forward to assisting.
        Hey your reply is 3 years old and in docs it states
        Configure User the presses the OK or Apply button.

        So can we rely on user input with AddPlot in current version 8.1.2.0 ?

        Comment


          #5
          Hello bukowa,

          Thanks for your notes.

          Yes, NinjaTrader_Jim's advice is correct and still relevant for NinjaTrader 8.1.2.0.

          From the AddPlot() help guide: This method should ONLY be called within the OnStateChange() method during State.SetDefaults or State.Configure

          Note that some properties based on loaded data or user input may not be available in State.Configure (I.E. Bars, Instrument, User Defined Inputs) so that may be a road block for what you are trying to add dynamically.

          AddPlot(): https://ninjatrader.com/support/help...lot.htm​
          Brandon H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bmartz, 03-12-2024, 06:12 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Started by Aviram Y, Today, 05:29 AM
          4 responses
          12 views
          0 likes
          Last Post Aviram Y  
          Started by algospoke, 04-17-2024, 06:40 PM
          3 responses
          28 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by cls71, Today, 04:45 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X