Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ReadOnly Property

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

    ReadOnly Property

    Hi,

    I have an indicator with a simple string property. I attach the ReadOnly[(true)] attribute to the property. The indicator compiles and works correctly. I now go back and change the value of the string property and recompile the indicator. The indicator now does not reflect the change made in the string value but retains the original value.

    I wonder if the ReadOnly attribute is working correctly in NT. I might be doing something stupid but for the world I cannot see it as this is a very simple string property. Any suggestions to fix this, or any insight into this would be greatly appreciated.Thank you.

    #2
    Hello Zeos6,
    Thanks for your post.

    Where are you setting the value for your string variable?

    If you are setting the string value inside State.SetDefaults you will need to remove the indicator from the chart and re-add it after compiling to see any changes.

    I look forward to you reply.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi JoshG,

      Thank you for your reply. I do set the value inside State.SetDefaults and I do remove the indicator from the chart and re-add it after compiling. The change does not appear. This is what makes me wonder whether the attribute works correctly or whether I am missing something.

      Comment


        #4
        Hello Zeos6,
        I suspect you are missing something. We have had no reports of other users having this issue and it works as expected on my end.

        Please provide a snippet of the property where you are setting [ReadOnlyAttribute(true)]
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hi JoshG,

          Here is the snippet...

          Code:
          [NinjaScriptProperty]
          [ReadOnly(true)]
          [Display(ResourceType = typeof(Custom.Resource), Name = "Indicator Version", GroupName = "Parameters", Order = 0)]
          public string Indicator_Version
          { get; set;}
          I know this can be done the old way with a backing field. And I know this can also be done with a getter only, but I can't figure out why this worked once and doesn't work any more.

          Thanks for your help Josh.

          Comment


            #6
            Hello Zeos6,
            Thanks for your note.

            That snippet works just fine for me. Please write in to PlatformSupport(at)NinjaTrader(dot)com and reference this forum post. I would like to take a look at your log and trace files as well as the indicator itself.

            You can export your indicator by going to Tools > Export > NinjaScript Add On > Add > select your indicator > OK > Export > name the file 'NTsupport' > Save.
            The file will be located under Documents\NinjaTrader 8\bin\Custom\ExportNinjaScript.

            You can include the above file with your log and trace files by going to the Control Center-> Help-> E-Mail Support.

            Ensuring 'Log and Trace Files' is checked will include these files and as the attachment add the above indicator.

            Thanks and I look forward to assisting you.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Thank you Josh.

              By the way...
              I removed the property from the indicator and now the indicator will not compile. The issue lies in the NT generated code. The indicator cache still has the property in it even though it has been removed from the code. That is weird.

              "There is compile time initialization, and there is run time initialization. As I understand NT expects that SetDefaults will re-create all compile time initialization as well as the normal run time initialization."I believe that this is not happening and what the indicator is doing is retrieving an incorrect instance from the internal pool.

              I have tested this as follows...
              I changed the property by removing the ReadOnly attribute. I manually changed its value in the property grid. This worked fine. Then I reinstated the ReadOnly attribute with a value assigned in State.SetDefaults. When I recompiled, the indicator showed the value manually input rather than the value set in State.SetDefaults. I believe that there is an issue with the internal pool.
              Last edited by Zeos6; 03-22-2018, 10:02 AM.

              Comment


                #8
                Have you saved the indicator in a template?
                eDanny
                NinjaTrader Ecosystem Vendor - Integrity Traders

                Comment


                  #9
                  No. The indicator was not saved inside a template.
                  I do however apply a ICustomTypeDescriptor to the indicator and I wonder if that is creating any issues.

                  EDIT: Thanks eDanny! That was indeed the issue. Thanks also to ChrisL at NT Support who figured it out and helped me with it. Thank you both ChrisL and eDanny. Much appreciated.
                  Last edited by Zeos6; 03-22-2018, 02:11 PM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by CortexZenUSA, Today, 12:53 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post CortexZenUSA  
                  Started by CortexZenUSA, Today, 12:46 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post CortexZenUSA  
                  Started by usazencortex, Today, 12:43 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post usazencortex  
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  168 responses
                  2,265 views
                  0 likes
                  Last Post sidlercom80  
                  Started by Barry Milan, Yesterday, 10:35 PM
                  3 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Working...
                  X