• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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

    Hello,

    I have read the documentation and the other thread with the same name. So my 2 plots and the Values are where they should be but still am getting the above error.

    My two plots are as per the documentation:


    if (State == State.SetDefaults)

    {
    AddPlot(Brushes.Blue, "PlotA"); // Defines the plot for Values[0]

    AddPlot(Brushes.Red, "PlotB"); // Defines the plot for Values[1]
    }

    protected override void OnBarUpdate()

    {
    Values[0][0] = GreenValue;

    Values[1][0] = RedValue;
    }

    The error happens even if I comment the lines AddPlot and Values!.

    I tried to copy and paste in a blank editor page all the code except NinjaScript generated code. But the problem persists.

    ​​​
    So which are the causes that can cause the above error?

    #2
    Originally posted by roblogic View Post
    Hello,

    ...

    protected override void OnBarUpdate()

    {
    Values[0][0] = GreenValue;

    Values[1][0] = RedValue;
    }

    ...
    So which are the causes that can cause the above error?
    not correct syntax, replace with these;
    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    Values[0][0] = High[0]; //GreenValue;
    Values[1][0] = Low[0]; //RedValue;
    }

    Comment


      #3
      Hello roblogic,

      Thanks for your post.

      Make sure that the error is from the actual file you are working on. When compiled, all scripts are compiled at the same time and an error is any file will be shown below the code you are working on. The first column of the error message identifies the file with the error.

      If member nkhoi's reply did not answer your question and you've confirmed the error is within the file you are working on, please post or attach your source code file.
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Thanks for your answers but I found the problem and probably it is something NT8 development should address. Please report that.

        The problem I had is that I created a file with the Editor. It compiled well but then when loading the indicator in the log there was the error above, so the indicator was not working. The problem is that I did a Save As of the file and saved it with a different name so the file that was compiling but giving the error was still in the indicators list. So I had to delete this original file that originated the problem to resolve the issue. Once this file was deleted the problem was gone and the indicator was loading and working fine.

        Comment


          #5
          Hello roblogic,

          Thanks for your reply.

          Could you clarify what the issue is that you feed should be reported to development?
          Can you provide a complete example that demonstrates the issue to be reported and the steps to recreate?
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            unfortunately i don't have the original files as I deleted them but here is what I did:

            1 Create a new indicator file that was compiling well but has the above error at runtime.
            2 Save as this file and create a new one. Now both files compile fine but have the error.
            3 Fix the error in the newer file. Both files compile fine but the older file still has the error. And AFAIR the error shown in the log refers to the newer file (not the old).
            4 So you have the fix or delete the older file in order for the newer file to run.

            Comment


              #7
              Hello roblogic,

              Thanks for your reply.

              I tried to recreate the issue of "error shown in the log refers to the newer file (not the old)." and was not able to. When the new file without the error runs, no run time error message is produced and this would be expected.

              If you should run into this again, please feel free to add to your post here or write into PlatformSupport[at]NinjaTrader[dot]com with the details so we can recreate.
              Paul H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by deblanka, Today, 08:56 AM
              0 responses
              3 views
              0 likes
              Last Post deblanka  
              Started by Boonfly8, Yesterday, 12:30 PM
              7 responses
              18 views
              0 likes
              Last Post sledge
              by sledge
               
              Started by Sohal, Today, 05:02 AM
              1 response
              8 views
              0 likes
              Last Post Sohal
              by Sohal
               
              Started by danitralla, Today, 03:33 AM
              0 responses
              5 views
              0 likes
              Last Post danitralla  
              Started by yeshujbp, Today, 12:37 AM
              0 responses
              14 views
              0 likes
              Last Post yeshujbp  
              Working...
              X