Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Syntax Problems

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #46
    I removed Close from the Variables section

    I corrected some misspellings (typos)

    After following your suggestion to look at the SMA Crossover strategy, I noticed that in the Variables section the variables were declared as private and started with lower case letters, as you mentioned, and in the Properties section the same Variables were listed as Public with first letters capitalized. I changed my code to conform.

    I thought this would eliminate the only remaining compiler error (properties repeat already declared variables). However, changing to match the SMA Sample code did not eliminate that compiler error.

    I believe I may have sent you a code listing incorrectly which may account for your saying that the errors you pointed out were still not correct. Attached is my latest code. I don’t know whether my latest changes have been saved because when I hit Save, the error message comes up and I can’t be sure the new code is saved.

    I believe all your corrections have been carried out and I am attaching this new code for help in clearing up the duplication of variables in the properties section. However, I noticed that in the SMA sample the same duplication exists.

    This has been a harrowing experience compared to coding in Easy Language. I have been studying C# as we go along but I must say that C# as an Object Oriented Programming language presents a formidable self-tutoring project. Also, there are differences between C# and the Ninja variety of it.

    I appreciate very much all your wonderful help and, in particular, your patience with me. Thanks again for your invaluable help.

    Open item: Correct compiler warning: Your strategy likely holds one or more recursive properties which could cause Ninja Trader to crash. It then lists all the property entries.
    Attached Files

    Comment


      #47
      Stan,

      You are missing the point. In Properties the ONLY capitalized variable name is in the public line. All others need to be lower case.

      This is what you have:
      Code:
      [Description("")]
              [Category("Parameters")]
              [COLOR=Red]private[/COLOR] int [COLOR=Red]l[/COLOR]ength
              {
                  get { return length; }
                  set { length = Math.Max(1, value); }
              }
      
              [Description("")]
              [Category("Parameters")]
              public int BSE
              {
                  get { return [COLOR=Red]B[/COLOR]SE; }
                  set { [COLOR=Red]B[/COLOR]SE = Math.Max(1, value); }
              }
      
              [Description("")]
              [Category("Parameters")]
              public int BSEp
              {
                  get { return [COLOR=Red]B[/COLOR]SEp; }
                  set { [COLOR=Red]B[/COLOR]SEp = Math.Max(1, value); }
              }
      
              [Description("")]
              [Category("Parameters")]
              public int MaxPosProf
              {
                  get { return [COLOR=Red]M[/COLOR]axPosProf; }
                  set { [COLOR=Red]M[/COLOR]axPosProf = Math.Max(1, value); }
              }
      
              [Description("")]
              [Category("Parameters")]
              public double BufferLong
              {
                  get { return [COLOR=Red]B[/COLOR]ufferLong ; }
                  set { [COLOR=Red]B[/COLOR]ufferLong = Math.Max(0.0001, value); }
              }
      
              [Description("")]
              [Category("Parameters")]
              public double [COLOR=Red]b[/COLOR]ufferShort
              {
                  get { return [COLOR=Red]B[/COLOR]ufferShort ; }
                  set { [COLOR=Red]B[/COLOR]ufferShort = Math.Max(0.0001, value); }
              }
      
              [Description("")]
              [Category("Parameters")]
              public int Ctr
              {
                  get { return [COLOR=Red]C[/COLOR]tr; }
                  set { [COLOR=Red]C[/COLOR]tr = Math.Max(1, value); }
              }
      Everything in red needs to be corrected.

      Please take a look at the SampleMACrossOver again. Pay close attention to which ones are capitalized and which ones are not.
      Josh P.NinjaTrader Customer Service

      Comment


        #48
        Skat,

        In all of your inputs at the bottom of the file your file, the input function and variable names are THE SAME. They cannot be. this is why you are receiving a recursive error.

        The proper nomenclature would be to use a capital letter for the first letter of the function name, and a lower case first letter for the variable name.

        Code:
                [Description("")]
                [Category("Parameters")]
                private int [COLOR=Red]L[/COLOR]ength
                {
                    get { return [COLOR=Red]l[/COLOR]ength; }
                    set { [COLOR=Red]l[/COLOR]ength = Math.Max(1, value); }
                }
        
                [Description("")]
                [Category("Parameters")]
                public int [COLOR=Red]B[/COLOR]SE
                {
                    get { return [COLOR=Red]b[/COLOR]SE; }
                    set { [COLOR=Red]b[/COLOR]SE = Math.Max(1, value); }
                }
        
                [Description("")]
                [Category("Parameters")]
                public int [COLOR=Red]B[/COLOR]SEp
                {
                    get { return [COLOR=Red]b[/COLOR]SEp; }
                    set { [COLOR=Red]b[/COLOR]SEp = Math.Max(1, value); }
                }
        
                [Description("")]
                [Category("Parameters")]
                public int [COLOR=Red]M[/COLOR]axPosProf
                {
                    get { return [COLOR=Red]m[/COLOR]axPosProf; }
                    set { [COLOR=Red]m[/COLOR]axPosProf = Math.Max(1, value); }
                }
        
                [Description("")]
                [Category("Parameters")]
                public double [COLOR=Red]B[/COLOR]ufferLong
                {
                    get { return [COLOR=Red]b[/COLOR]ufferLong ; }
                    set { [COLOR=Red]b[/COLOR]ufferLong = Math.Max(0.0001, value); }
                }
        
                [Description("")]
                [Category("Parameters")]
                public double [COLOR=Red]B[/COLOR]ufferShort
                {
                    get { return [COLOR=Red]b[/COLOR]ufferShort ; }
                    set { [COLOR=Red]b[/COLOR]ufferShort = Math.Max(0.0001, value); }
                }
        
                [Description("")]
                [Category("Parameters")]
                public int [COLOR=Red]C[/COLOR]tr
                {
                    get { return [COLOR=Red]c[/COLOR]tr; }
                    set { [COLOR=Red]c[/COLOR]tr = Math.Max(1, value); }
                }
        Take a look.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #49
          Don't forget to make your Length public there as well.
          Josh P.NinjaTrader Customer Service

          Comment


            #50
            Syntax Errors

            All mentioned errors now corrected.

            Now have a new list of errors regarding comparisons of Performance.Unit.Currency with various input variables declared as int. I don't see any mention of Currency as a type.

            In the expression:

            && Position.GetProfitLoss(Close[
            0], (PerformanceUnit.Currency) < bSEp)) , bSEp is an integer input variable and apparently is not permitted tobe compared with PerformanceUnit.Currency.

            How can I correct this?

            Comment


              #51
              You can't do it like that:
              Position.GetProfitLoss(Close[0], (PerformanceUnit.Currency) < bSEp))

              It needs to be done like this:
              Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) < bSEp

              You need to be mindful of which parenthesis closes what and which brackets close what.
              Josh P.NinjaTrader Customer Service

              Comment


                #52
                Syntax Errors

                In following Condition, compiler does not allow the comparison operator >= between expression and double (maxPosProf).

                // Condition set 0 sets Trailing Stop
                if(Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= maxPosProf )
                {
                SetTrailStop(
                "TS.LRC", CalculationMode.Price, 50, true) ;
                }

                How do I correct?

                Comment


                  #53
                  skat100,

                  You can't compare doubles to integers like that. GetProfitLoss() is going to return a double so you need to compare it to another double. You need to ensure that maxPosProf is a double.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #54
                    Syntax Errors

                    maxPosProf is indeed a double as declared in Vars and as it appears in Properties.

                    Seems like the more we correct compile errors, the more errors come on to haunt us.

                    Reminds me of an old Quaker saying, "The faster I run, the behinder I get."

                    Any suggestions?

                    Comment


                      #55
                      Post the code please. The last iteration you had it was an int.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #56
                        Compile Errors

                        Code attached.
                        Attached Files

                        Comment


                          #57
                          Stan,

                          You keep changing the code.

                          Before you posted this:
                          if
                          (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) >= maxPosProf )

                          Now your code says this:
                          if(Position.GetProfitLoss(Close[0], PerformanceUnit.Currency > maxPosProf))

                          You need to be mindful of where the parentheses are going. They need to close the correct set. You can't just start moving things in and out of the parenthesis. It was correct the first time you posted.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #58
                            No longer have any compiler errors. I would now like to take the next steps toward running an automated mini account. If possible, I would like to try this out on a simulated basis. If not, then live.

                            Would you please tell me what are the next steps toward this goal?

                            Thanks for your help.

                            Comment


                              #59
                              To try it out just go ahead and connect to your live data provider. Throw the strategy onto the chart and then you will be testing it out. Make sure you select the Sim101 account when you are starting up your strategy. I recommend you go to the File menu in the Control Center and check the "Global Simulation Mode" option.
                              Josh P.NinjaTrader Customer Service

                              Comment


                                #60
                                Global Simulation mode is grayed out.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                599 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                344 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                103 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                558 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                557 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X