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

Cannot save workspace, indicator error message, no idea why

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

    Cannot save workspace, indicator error message, no idea why

    So I have a bunch of indicators I have been working on. I have a bunch of charts I have created with various indicators and combos of indicators.

    When I try to save my workspace, I am getting the following error in the NinjaScript Output:

    Could not save indicator 'IndicatorName'. There was an error reflecting type 'NinjaTrader.NinjaScipt.Indicators.IndicatorName'

    And I get that for every indicator on every chart I have. No idea what to look at to resolve this. The charts are loading fine, and I don't get any output errors from the charts when loading or even reloading. Can anyone help me dig into this? My indicators are pretty much worthless if I can't save my workspace.

    #2
    Hello ErikY,

    Thanks for the post.

    The first step at a solution is always to reduce what is happening to isolate the issue. If you were working on multiple custom items and now see this it is likely a result of something in those items. Please try closing all workspaces and open a new workspace with an empty single chart. Apply one of your items and save the new workspace. If you get the error that will cut out a lot of other variables. Try this for each item individually to check which are working and which are not for all the custom items you made.

    Once the scripts having the errors are known you can start to address the problem in the code. The error you are seeing is generally caused by using the incorrect attributes for a public property. A common way to find the problem with saving/loading a workspace and indicator would be to use the following steps:
    1. Comment the logic out you created in your indicator, that would include all the code in OnBarUpdate or other overrides you used.
    2. Comment out all public properties you created and comment out where they are used in State.SetDefaults.
    3. Compile and clear any other errors caused by commenting out your code.

    Once the code is compiled check if you can save the workspace, if so now do the following:
    1. Uncomment a few public properties
    2. Compile
    3. Test saving and loading
    4. Repeat

    You should see the error come up at some point which will point to a more specific point in your code. Once you know the general code you can provide that and we can take a look to see what may be happening. You can also attach one of the indicators and I can take a quick look to see if I can notice anything obvious.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse. This one is going to be tricky. I just simplified one chart to one indicator, and I commented out all 3 public properties and still having same issue. Trick is commenting out sections of code and still getting the indicators to run. Is there anyway to dig into a log or anything else to get more direction on this? Feels like finding a needle in a haystack.

      Comment


        #4
        Hello ErikY,

        Thanks for the reply.

        Keeping the script working shouldn't be a concern here, the point of this test is simply to find what part is making the error. The script doesn't actually need to work at all, it just needs to compile and be able to be applied and also save.

        You can look at the log to see if any other relevant information is reported but with this type of error it may not be. In some cases it may have additional information like the property name, that would be in the log tab where you see the error listed if so. If there is no other information and you simply see error reflecting the type that will require a little bit of digging in the code. The fastest way is just commenting big chunks out until your left with a bare bones script that can save and still has your commented code in it. Once you reach that point its just a process of elimination uncommenting the code until you find the problem again.

        Areas which cause problems with saving would be items that are public such as variables you make or properties you make. That can also include more advanced items like classes. After you comment everything out the quickest way forward is to uncomment anything that is public first and see if it saves.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          OK, after a lot of commenting and uncommenting out, the culprit seems to be that I am setting:

          public series<int> myVariable;


          if I change it to:

          private series<int> myVariable


          I can save the workspace.

          The problem is I do need that to be public because I need to access the data in other indicators that I am using this indicator inside of.

          Any reason why it would not allow me to use a public series, and any workarounds here?

          Comment


            #6
            Hello ErikY,

            Thanks for the reply.

            Good to see you found the line, this is correct because a series cannot be saved in the workspace. To make this public but prevent it from being saved you need to add the xml ignore attribute: https://ninjatrader.com/support/help...hlightsub=attr

            There is also a sample that covers creating a few different types of public variables and shows using XMLIgnore: https://ninjatrader.com/support/help...alues_that.htm

            As a side note here you would see this type of problem with any complex property that's not able to be made into a simple string. That would include items like Brushes or a List as an example. Depending on the type of property and if it needs saved or not you can use attributes or logic to control saving or not saving the property .

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Awesome, thanks very much. I think this has solved the problem. Really appreciate the support offered here, its fantastic!!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by f.saeidi, Today, 10:19 AM
              0 responses
              2 views
              0 likes
              Last Post f.saeidi  
              Started by kujista, Today, 06:23 AM
              4 responses
              15 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by traderqz, Yesterday, 09:06 AM
              2 responses
              16 views
              0 likes
              Last Post traderqz  
              Started by traderqz, Today, 12:06 AM
              3 responses
              6 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by RideMe, 04-07-2024, 04:54 PM
              5 responses
              28 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X