• 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

Custom Type Converter is displaying an error in the NT Log only after compiling

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

    Custom Type Converter is displaying an error in the NT Log only after compiling

    I have a property that uses a custom type converter to display a list of true/false options in an expandable list. The custom type converter is a subclass of ExpandableObjectConverter which is the standard way of creating an expandable list.

    Here is the problem:
    Every time a compile the indicator and then reload the the indicator I get an error in the Ninjatrader log that says " Failed to set property 'MyTestType' for indicator 'TestTypeConverter': Object of type 'MyNamespace.TestType' cannot be converted to type 'MyNamespace.TestType'.

    However, the property is being set properly.

    This error will only be displayed once. If I reload the indicator again I do not get the error message.

    I can even close the NinjaTrader application and then reopen it and the error message will not display again.

    So basically the indicator works fine. However, my concern is that if a person is using this indicator on their charts and then they decide to recompile any other indicator, then whenever they load my indicator for the first time or even refresh an existing indicator of mine then this error will appear in the log and the user may think something is wrong.

    Does anyone know why this error is only happening after a compile?

    Thanks
    P.S. I have included the source code below. You should be able to just copy it directly.
    Attached Files

    #2
    OK. so now I know that it is not something that I was doing wrong: I have the same problem, also because I am using a class to gather user input.

    Sorry that I cannot offer a solution. Indeed I am here to beg you to please publish the solution, if you are able to find one.

    Comment


      #3
      bmont,

      Thanks for your note.

      I was unable to replicate your issue the first time I loaded the indicator, but upon compiling a second time and reloading the indicator I did get this error message.

      Unfortunately coding on this level is unsupported, so hopefully someone in the community has a resolution. I will look into it further but I cannot promise a resolution quickly as first and foremost we must take care of supported issues.

      I suspect you are missing some code that would allow the compiler to interpret this appropriately.

      Please let me know if I may assist further.
      Last edited by NinjaTrader_AdamP; 11-23-2011, 12:57 PM.
      Adam P.NinjaTrader Customer Service

      Comment


        #4
        I have used TypeConverters in the past, was tricky, but it should work.

        Just from a glance at your code:

        Try putting the full class name including namespace:

        [TypeConverter(typeof(MyNamespace.TestTypeObjectCon verter))]
        public MyNamespace.TestType MyTestType
        {



        andreas

        Comment


          #5
          I've had similar issues, but under different circumstances. It seems the problem lies in the fact that your custom type persists between reloads of ninjascript, and is not disposed of with the rest of the indicator. The reason it happens only after a re-compile is that NT creates a new NinjaTrader.Custom.dll (it also generates a temporary version) and NT loses track of the undisposed type when ninjascript is reloaded again.

          My solution was to put a check in to see if there was a "recompile" done after the indicator had been added to a chart. If it has been recompiled, then your type will have to be disposed of separately, and you can't count on the normal disposal of the indicator.

          Like I said, my circumstances were different, but the effect was the same. I would get an error, only after a recompile of any indicator since my indicator was applied to a chart.

          Hope this helps.

          VT

          Comment


            #6
            Vtrader's comment makes sense.
            At this point you should put the typeconverter code in its own dll.

            Andreas

            Comment


              #7
              Thanks Andreas

              But things just got worse by moving them to their own DLL. I have seen this happen over and over again on the NinjaTrader platform. Whenever type converters and/or UITypeEditors are placed in a separate assembly they are no longer recognized by Ninjatrader. The indicators will still compile without warnings but they are not recognized by the settings property editor. This has been extremely frustrating. Many of the things I am trying to do should just work in a "normal" .NET environment. I will follow up with the steps that I took to put the TypeConverter in a separate assembly.

              Comment


                #8
                I have confirmed - as VTTrader mentioned in Post#5- that the user defined type is not disposed between recompiles of the NinjaTrader.Custom.dll.

                My question is.... how do I check to see if it has been recompiled. Do you have some example code on how to do this?

                Thanks

                Comment


                  #9
                  bmont,

                  The way I checked was using LastWriteTime, and basically compare timestamps.

                  fi = new FileInfo(NinjaTrader.Cbi.Core.UserDataDir.ToString() + @"bin\Custom\NinjaTrader.Custom.dll");
                  fileTime = fi.LastWriteTime;
                  VT

                  Comment


                    #10
                    I am hitting this same problem. Has anyone come up with a good answer for it? I even tried adding a conversion to the same type to the type converter, but that did not help.

                    I suppose it is not earth-shaking, but it is pretty darned annoying.

                    --EV
                    Last edited by ETFVoyageur; 03-18-2014, 05:32 PM.

                    Comment


                      #11
                      This is an old post. If anyone is still having the issue in NT8, I can post a solution.

                      Wil

                      Comment


                        #12
                        yes, please post your solution

                        Comment


                          #13
                          Originally posted by bltdavid View Post
                          yes, please post your solution
                          You need to implement it as ICloneable, and, of course, define a Clone() method. Often, just the default, base, shallow clone, Object.MemberwiseClone() method is sufficient.

                          Comment


                            #14
                            Implement it where?
                            On the TypeConveter classs?

                            Comment


                              #15
                              Originally posted by bltdavid View Post
                              Implement it where?
                              On the TypeConveter classs?
                              They have documented it rather quietly as an example.

                              ref: https://ninjatrader.com/support/foru...-grid-behavior

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ralett, Yesterday, 07:29 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Marco  
                              Started by bboyle1234, Yesterday, 10:46 PM
                              1 response
                              7 views
                              0 likes
                              Last Post bltdavid  
                              Started by swcooke, Yesterday, 04:29 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post swcooke
                              by swcooke
                               
                              Started by bboyle1234, Yesterday, 04:27 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post bboyle1234  
                              Started by swcooke, Yesterday, 03:31 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post swcooke
                              by swcooke
                               
                              Working...
                              X