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

Wizard-Generated Code Produces Error Messages CS0119 & CS0103

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

    Wizard-Generated Code Produces Error Messages CS0119 & CS0103

    This wizard-generated code produces error messages CS0119 & CS0103. Why?

    // Condition set 1
    if (TCZScore(100, 10, NinjaTrader.Indicator.TCZScore+MovingAverageTypes. SMA, 5, 100).Z[0] > TCZScore(100, 10, NinjaTrader.Indicator.TCZScore+MovingAverageTypes. SMA, 5, 100).ZSmooth[0])
    {
    }

    #2
    Hello ScorpioTravis,

    This may indicate an issue with the code in the custom TCZScore indicator.

    Does this also occur when selecting the ADL or SMA indicator?

    What is the full error message including line numbers. (Ctrl + c to copy, Ctrl + v to paste)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Indicator\TCZscore.cs 'NinjaTrader.Indicator.TCZScore' is a 'type', which is not valid in the given context CS0119
      Indicator\TCZscore.cs The name 'MovingAverageTypes' does not exist in the current context CS0103
      Indicator\TCZscore.cs 'NinjaTrader.Indicator.TCZScore' is a 'type', which is not valid in the given context CS0119
      Indicator\TCZscore.cs The name 'MovingAverageTypes' does not exist in the current context CS0103

      Comment


        #4
        Hello ScorpioTravis,

        This would suggest the TCZscore indicator you have created is not designed to work in the Strategy Wizard.

        This may be an issue with enums. May I confirm that enums in the TCZscore indicator are in a custom namespace and referenced with the fully qualified namespace?

        Below is a link to an example.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I am not a programmer, so I don't fully understand your question. Is this what you are asking about?

          namespace NinjaTrader.Indicator
          {
          /// <summary>
          /// Displays Z Score for the selected instrument.
          /// </summary>
          [Description("Displays Z Score for the selected instrument. Optional Smoothings.")]
          public class TCZScore : Indicator
          {
          public enum MovingAverageTypes
          {
          SMA = 1,
          WMA = 2,
          EMA = 3,
          LinReg = 4
          }

          Comment


            #6
            Hello ScorpioTravis,

            Move the public enum outside of the indicator class below as shown in the example I have provided you. I recommend moving the enums to a custom namespace.

            namespace TCZScoreEnums
            {
            public enum MovingAverageTypes
            {
            SMA =1
            }
            }
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              In which section does the namespace go?

              Comment


                #8
                Hello ScorpioTravis,

                Put the below the indicator class. In the SampleUniversalMovingAverage_NT7 the public enum is there. I suggest a custom namespace to prevent conflicts with other scripts. The version for NinjaTrader 8 demonstrates the custom namespace.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I placed it after the second curly braces after the Properties section with its last of two curly braces before the line: +NinjaScript generated code.
                  Properties
                  }
                  }
                  namespace TCZScoreEnums
                  {
                  public enum MovingAverageTypes
                  {
                  SMA = 1,
                  WMA = 2,
                  EMA = 3,
                  LinReg = 4
                  }
                  }

                  Now I get errors for each of the MA types:

                  Indicator\TCZScore.cs The type name 'MovingAverageTypes' does not exist in the type 'NinjaTrader.Indicator.TCZScore' CS0426 - click for info

                  as well as:

                  Indicator\TCZScore.cs The type or namespace name 'MovingAverageTypes' could not be found (are you missing a using directive or an assembly reference?) CS0246

                  which refers to Variable

                  private MovingAverageTypes mAType = MovingAverageTypes.SMA; // 1=SMA, 2=EMA, 3=LinReg

                  I understand if this getting beyond what you normally support in the forum.

                  Comment


                    #10
                    Hello ScorpioTravis,

                    Use the namespace with the usage of MovingAverageTypes within the indicator.

                    public TCZScoreEnums.MovingAverageTypes MyAverageType.

                    Have a look at the SampleUniversalMovingAverage_NT8 which demonstrates on line 33, 55, 91 etc.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by fx.practic, 10-15-2013, 12:53 AM
                    5 responses
                    5,404 views
                    0 likes
                    Last Post Bidder
                    by Bidder
                     
                    Started by Shai Samuel, 07-02-2022, 02:46 PM
                    4 responses
                    95 views
                    0 likes
                    Last Post Bidder
                    by Bidder
                     
                    Started by DJ888, Yesterday, 10:57 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by MacDad, 02-25-2024, 11:48 PM
                    7 responses
                    160 views
                    0 likes
                    Last Post loganjarosz123  
                    Started by Belfortbucks, Yesterday, 09:29 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post Belfortbucks  
                    Working...
                    X