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

Compile Errors

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

    Compile Errors

    I have converted this indicator from NT7 to NT8 and cannot get it to compile error free. The compile error I'm getting is "'int' does not contain a definition for 'SetDefaults' and no extension method 'SetDefaults' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)". I have tried finding the problem with no luck. Any help would be appreciated.
    Attached Files

    #2
    Hello mlarocco,

    You have a variable named State however NinjaScript already contains a variable named State:

    Code:
     private int             State
    You would need to make this variable into any other name that is not already in use.


    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Ok, I changed the private int to StateRange and it compiles error free, now the problem is, it doesn't show in the indicator list. I'm pulling what little hair I have left out! lol
      Attached Files

      Comment


        #4
        Hello mlarocco,

        Are you seeing any errors when opening the indicators menu listed in the control center -> Logs tab?

        It looks like you are trying to copy the "Initialize" override from NT7 one for one however a lot of that syntax has changed with NT8. There is no longer a single starting point or Initialize, instead there is a state system composed of multiple different states.

        Before continuing with your conversion, I would strongly suggest looking at the SMA indicators code to see how the default structure of a script should look and try to model your script after that structure. You can also see the SampleMultiTimeframe strategy for an example of creating a multi series script and its structure. I see you are using properties which do not belong in State.SetDefaults but belong in other states later in your scripts initialization process so you will likely need to go line by line and make sure the code belongs where you have it.

        You can also find samples for most NinjaScript methods and properties in the help guide such as AddDataSeries: https://ninjatrader.com/support/help...ghtsub=adddata

        This needs to go in State.Configure but you have it in State.Defaults.

        You can find more information about OnStateChange here: https://ninjatrader.com/support/helpGuides/nt8/en-us/onstatechange.htm?zoom_highlightsub=onstatechange

        I would also suggest reviewing the code breaking changes guide: https://ninjatrader.com/support/help...ng_changes.htm

        I look forward to being of further assistance.
        Last edited by NinjaTrader_Jesse; 05-21-2019, 11:42 AM.
        JesseNinjaTrader Customer Service

        Comment


          #5
          I do see errors in the Log tab...
          Attached Files
          Last edited by mlarocco; 05-21-2019, 11:43 AM.

          Comment


            #6
            Hello mlarocco,

            Yes in this case the error states the problem, you are calling AddDataSeries in the wrong location. For this part of the question you can find samples of the correct syntax in the items I had mentioned or:

            You can also find samples for most NinjaScript methods and properties in the help guide such as AddDataSeries: https://ninjatrader.com/support/help...ghtsub=adddata
            This needs to go in State.Configure but you have it in State.Defaults.
            You can find more information about OnStateChange here: https://ninjatrader.com/support/help...=onstatechange
            In this situation comparing what you have made against something which is known to work (SMA or SampleMultiTimeframe) can help to highlight the problems. The code you have created in the Initialize() method will need to be modified to look like the other indicators/samples you see in NT8. Right now you are calling AddDataSeires in the state SetDefaults:

            Code:
            protected override void OnStateChange()
                    {
                        switch (State)
                        {
                            case State.SetDefaults:
                                Name = "ETOpeningRange_NT8";
                                Description = "Opening Range indicator";
            [B]  Initialize();    // <---- running all your code for State.SetDefaults [/B]
                                break;
                         }
                    }
            You would instead need to make your code look like the help guide or other scripts show and have mutliple states:

            Code:
            if (State == State.SetDefaults)
              {
                 //some default properties will be configured here
              }
            
              else if (State == State.Configure)
              { 
               // add data series goes here, State.Configure
                AddDataSeries("AAPL", BarsPeriodType.Minute, 5);     
              }
            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              I'm afraid this is getting a little over my head.... Thanks for your help!

              Comment


                #8
                Originally posted by mlarocco View Post
                I'm afraid this is getting a little over my head.... Thanks for your help!
                mlarocco,

                Do you now have a working ETOpeningRange_NT8 ? Could you please share it with me.

                Regards.

                Lolu

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by kujista, Today, 05:44 AM
                0 responses
                1 view
                0 likes
                Last Post kujista
                by kujista
                 
                Started by ZenCortexCLICK, Today, 04:58 AM
                0 responses
                5 views
                0 likes
                Last Post ZenCortexCLICK  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                172 responses
                2,281 views
                0 likes
                Last Post sidlercom80  
                Started by Irukandji, Yesterday, 02:53 AM
                2 responses
                18 views
                0 likes
                Last Post Irukandji  
                Started by adeelshahzad, Today, 03:54 AM
                0 responses
                8 views
                0 likes
                Last Post adeelshahzad  
                Working...
                X