Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddPlot to existing indicator

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

    AddPlot to existing indicator

    Is it possible to manually code an additional plot to an existing indicator? I'm having no luck.

    I have a custom indicator. I would like to add an additional plot with it's own values, to the same indicator.

    I do not understand how the Values[] are tied to the AddPlot() that I put into the OnStateChange method, state.defaults. I assumed that the compiler would read that AddPlot() and dimension the Values series accordingly, but it doesn't seem so.

    I am unable to assign a value to Values[1][0]. I keep getting an error that the value I'm trying to access is "out of range." I have read the Values and AddPlot() instructions but still can't figure this out. Since adding the second plot was an afterthought, I really didn't want to have to go back through the wizard and start over.

    #2
    Hello Chippy,

    Yes, AddPlot() will automatically add a Series<double> to the Values collection. The first plot added is Values[0], the next call to AddPlot() becomes Values[1], etc.

    Below is a link to the help guide..


    Note, that State.SetDefaults is only called when adding a new instance of a script. Remove and re-add the instance from the chart to re-run the code in this area. (meaning don't just refresh the ninjascript, actually remove the instance and add a new instance)

    If Values.Count is 0, this might indicate an error with the AddPlot() call. Do you see errors appearing on the Log tab of the Control Center?

    With Values[1], may I confirm that AddPlot() was called at least 2 times without error in the Log?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea. I found a work-around, but I was never able to get the multidimensional array syntax to work. I was having trouble with the added plot being based on cumulative data and hadn't instantiated it or initialized it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      573 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      575 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X