Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on calling 'OnStateChange' method: Added Plots or Lines must have a unique name

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

    Error on calling 'OnStateChange' method: Added Plots or Lines must have a unique name

    I added my indicator and saved it as template and opened 5 other symbols to use the template. i keep getting a error on the log
    My code shows the nams are unique,
    Code:
     protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description = @"Enter the description for your new custom Indicator here.";
                    Name = "S_Trading_System";
                    Calculate = Calculate.OnEachTick;
                    IsOverlay = false;
                    DisplayInDataBox = true;
                    DrawOnPricePanel = true;
                    DrawHorizontalGridLines = true;
                    DrawVerticalGridLines = true;
                    PaintPriceMarkers = true;
                    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event. 
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive = true;
                    AddPlot(Brushes.Orange, "Mean");
                }
                else if (State == State.Configure)
                {
                    AddPlot(Brushes.Aqua, "EMA 9");
                    AddPlot(Brushes.DarkGray, "EMA 22");
                }
            }

    #2
    Hello,

    Thank you for the question.

    This error would be the result of using the incorrect state for two of your plots.

    You would just need to move the AddPlot statements from Configure into SetDefaults.

    Please see the help guide for a full example: http://ninjatrader.com/support/helpG...ghtsub=addplot

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    672 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    379 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    111 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    577 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    582 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X