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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      72 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      152 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      100 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      288 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X