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

Compiling is awfully fragile

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

    Compiling is awfully fragile

    I have run into the occasional problem in the past, and I have seen complaints by others. I am posting now because I have had several problems just tonight.

    *) I removed a property from an indicator and got compiler errors in the Magic Code. Some code there still referred to the property I just removed. I never was able to get that to work, so I just made a new demo indicator, named it the same as my old one, and then cut-and-pasted the entire contents of my old one into the demo indicator. Compiles just fine.

    *) I added a [Category("string")] attribute to a property in a demo indicator I was doing. That provoked a compile failure in the Magic Code. I solved my problem by combining it with a Description attribute: [Category("string"), Description("string)], which compiles just fine. Obviously Category attributes work in general -- I don't know what is special about this case. The following case fails:
    Code:
            [ Description("Demonstration of a class as a property")]
            [GridCategory("Parameters")]
            public Point testPoint { get; set; }
    The following case compiles just fine:
    Code:
            [GridCategory("Parameters"), Description("Demonstration of a class as a property")]
            public Point testPoint { get; set; }
    *) I have [Description("string")] attributes on each of the values of an enum in a demo indicator, and that works fine. I did the same thing in my real indicator and it got a compiler error in the Magic Code. So I removed the attributes and tried to recompile. At that point I could not recompile, nor could I save the file. That window is just hung. The rest of NT is OK -- just that one window hung. I could find no way to recover other than go to Control Center and exit, then restart. I tried the same thing when NT restarted, and got the same result. Excuse me ... I really cannot remove some text from the source and then recompile? (I'm still working on figuring that one out.)

    *) When I did exit, I got a message box and a sound. The message box was entirely blank. Before I had a chance to try to click the button NT just close the message box and continued to exit.

    Hmmm....

    --EV

    #2
    I was partially wrong about one thing -- that window is not totally hung. I can edit text in it, for example -- not worth much since I still cannot either save my changes or do a compile. I also do not have to exit NT -- that was overkill. I can click on the window's "X" button to kill the window. It asks whether to save -- choosing yes just leaves the window as it was. Choosing not to save allows killing the window.

    This text is OK -- the compile fails, but at least I can save the file and I can try to compile.

    Code:
         public enum TrendType {
            //[Description("No trend coloring")]                None,
            None,
            //[Description("Crossing the signal line")]        SignalLine,
            SignalLine,
            //[Description("Linear regression slope")]        Slope,
            Slope,
            //[Description("Above or below the center band")]    CenterBand,
            CenterBand,
            [Description("Above or below zero")]            ZeroCrossing }
    This text fails -- it is identical to the previous, except for commenting out the last enum description & value and adding an uncommented equivalent. Once I edit from the previous text to this I can no longer either compile or save the file. Editing the text back (I can still do that) does not help -- even when the text is back to the way it was I cannot compile or save the file.

    Code:
        public enum TrendType {
            //[Description("No trend coloring")]                None,
            None,
            //[Description("Crossing the signal line")]        SignalLine,
            SignalLine,
            //[Description("Linear regression slope")]        Slope,
            Slope,
            //[Description("Above or below the center band")]    CenterBand,
            CenterBand,
            //[Description("Above or below zero")]            ZeroCrossing }
            ZeroCrossing }
    ????

    --EV
    Last edited by ETFVoyageur; 02-16-2014, 06:28 AM.

    Comment


      #3
      There is a limitation of the inbuilt NinjaTrader editor. As far as I remember commenting out with "/*" and "*/" does not work in the property section.

      I understand that your problem is different, but in any case I would try to avoid to outcomment if you are having problems.

      Comment


        #4
        Originally posted by Harry View Post
        There is a limitation of the inbuilt NinjaTrader editor. As far as I remember commenting out with "/*" and "*/" does not work in the property section.

        I understand that your problem is different, but in any case I would try to avoid to outcomment if you are having problems.
        I still do not understand why it so easily got into a state where it would neither compile nor even save the file. It seems pretty rude to do that. Thank goodness I could edit the file with notepad++ as needed.

        As to the actual problem -- it was evidently confused, so the error messages when t did compile were not helpful. I did finally figure out the problem -- it was confused when I did that to an enum that was in the namespace, but not in the indicator class. I fixed the problem by moving the enum to right above the property declaration in the class. Works fine now. Go figure.

        --EV

        Comment


          #5
          The enum should be used as a global type, so it is not helpful to put it into the property section. Usually, if you do nothing wrong, NinjaTrader compiles fine ..... You can also use SharpDevelop or Visual Studio to edit and modify your files.
          Last edited by Harry; 02-16-2014, 12:16 PM.

          Comment


            #6
            Originally posted by Harry View Post
            The enum is a global variable, so you cannot put it into the property section. Usually, if you do nothing wrong, NinjaTrader compiles fine ..... You can also use SharpDevelop or Visual Studio to edit and modify your files.
            I do not understand. First of all an enum is not a variable, it is a type. Secondly, according to the Microsoft reference, an enum can have modifiers (new, public, protected, internal, private).

            What makes you say that an enum declaration is global?

            --EV

            Comment


              #7
              Originally posted by ETFVoyageur View Post
              I do not understand. First of all an enum is not a variable, it is a type. Secondly, according to the Microsoft reference, an enum can have modifiers (new, public, protected, internal, private).

              What makes you say that an enum declaration is global?

              --EV
              It should be used as global type to allow other indicator and strategies to select the enum as input parameter when the indicator is called.

              Comment


                #8
                Originally posted by Harry View Post
                It should be used as global type to allow other indicator and strategies to select the enum as input parameter when the indicator is called.
                Perhaps we are just talking words-- it is declared public. Won't that meet your need?

                --EV

                Comment


                  #9
                  Originally posted by Harry View Post
                  The enum should be used as a global type, so it is not helpful to put it into the property section. Usually, if you do nothing wrong, NinjaTrader compiles fine ..... You can also use SharpDevelop or Visual Studio to edit and modify your files.
                  An enum can have a scope modifier, so you can place it wherever you want, as long as you scope it properly. There is no restriction that it must be global. I certainly have enums that are not global, because I only use them internally, with no need for public exposure.

                  Comment


                    #10
                    Originally posted by koganam View Post
                    An enum can have a scope modifier, so you can place it wherever you want, as long as you scope it properly. There is no restriction that it must be global. I certainly have enums that are not global, because I only use them internally, with no need for public exposure.
                    I think you and I agree:
                    • If the enum is part of the interface, it should be public
                    • If the enum is internal, not part of the interface, it should not be externally visible.

                    --EV

                    Comment


                      #11
                      How do I get the Magic Code regenerated?

                      I just ran into one of my pet peeves again -- I had the nerve to remove a property from the indicator and now the Magic Code will no longer compile. CS1061 -- does not contain a definition for the property I just removed.

                      It is also unhappy if I rename the property or change its protection level.

                      --EV
                      Last edited by ETFVoyageur; 02-17-2014, 06:23 AM.

                      Comment


                        #12
                        Originally posted by ETFVoyageur View Post
                        How do I get the Magic Code regenerated?

                        I just ran into one of my pet peeves again -- I had the nerve to remove a property from the indicator and now the Magic Code will no longer compile. CS1061 -- does not contain a definition for the property I just removed.

                        It is also unhappy if I rename the property or change its protection level.

                        --EV
                        Is your description of the class a single string or a string expression?

                        Comment


                          #13
                          Hello EV,

                          Thank you for your post and to Harry and koganam for their assistance.

                          If you are removing sections of code you need to ensure you remove all references to the removed variables, properties, methods, etc. Where are you removing the properties? Are you removing the information under the following lines?
                          Code:
                          #region NinjaScript generated code. Neither change nor remove.
                          // This namespace holds all indicators and is required. Do not change it.
                          namespace NinjaTrader.Indicator
                          {

                          Comment


                            #14
                            Originally posted by koganam View Post
                            Is your description of the class a single string or a string expression?
                            The property had no attributes. It was the int property generated by the wizard when making a new indicator.

                            --EV

                            Comment


                              #15
                              Originally posted by NinjaTrader_PatrickH View Post
                              Hello EV,

                              Thank you for your post and to Harry and koganam for their assistance.

                              If you are removing sections of code you need to ensure you remove all references to the removed variables, properties, methods, etc. Where are you removing the properties? Are you removing the information under the following lines?
                              Code:
                              #region NinjaScript generated code.[COLOR=Blue] Neither change nor remove.[/COLOR]
                              // This namespace holds all indicators and is required. Do not change it.
                              namespace NinjaTrader.Indicator
                              {
                              I removed a property generated by the new-indicator wizard. I did remove any reference to it from my code (there were none) as evidenced by the only compiler errors being in the Magic Code where it still referenced the departed property.

                              I did not edit the Magic Code. I was expecting that there must be a pre-compile step to update the Magic Code as needed, but evidently not. Are you suggesting that I ought to edit the Magic Code to reflect the change in my indicator? I'd rather have NT rebuild it.

                              --EV
                              Last edited by ETFVoyageur; 02-17-2014, 03:30 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              9 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              0 responses
                              14 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Yesterday, 08:42 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post carnitron  
                              Started by strategist007, Yesterday, 07:51 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,983 views
                              3 likes
                              Last Post jhudas88  
                              Working...
                              X