• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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";
              Initialize();    // <---- running all your code for State.SetDefaults 
                                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

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by vantojo, Today, 08:35 AM
              1 response
              2 views
              0 likes
              Last Post NinjaTrader_PatrickG  
              Started by frankduc, Today, 08:28 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by EddieBeanPit, 06-21-2019, 07:17 PM
              1 response
              19 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by futures2018!, Yesterday, 05:01 PM
              3 responses
              13 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Splex, Today, 12:04 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Jim  
              Working...
              X