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

NT7 to NT8 conversion. ArrayList compile error

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

    NT7 to NT8 conversion. ArrayList compile error

    Hello.

    Hoping for some help or guidance.

    I've managed to convert all parts of an NT7 indicator to NT8 except one section.


    I'm getting the following compile error:-

    Click image for larger version

Name:	NT8 Compile error - Array List_a.jpg
Views:	150
Size:	16.9 KB
ID:	1204704

    The error refers to:-

    Click image for larger version

Name:	NT8 Compile error - Array List_b.jpg
Views:	131
Size:	12.3 KB
ID:	1204705



    Appreciate any help to convert it from NT7 to NT8.


    Many thanks

    #2
    Hello dj22522,

    Thanks for your post.

    This error is indicating that you are missing a using directive or assembly reference for the ArrayList Class.

    In your script, you would need to add the using directive System.Collections to the Using Declarations section at the top of your script.

    For example: using System.Collections.

    See this publicly available link for more information about using the ArrayList class: https://docs.microsoft.com/en-us/dot...t?view=net-6.0

    Let us know if we may assist further.

    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Google "C# ArrayList".

      Click on the Microsoft documentation for ArrayList,
      this is usually the first link.

      Towards the top, you'll see the namespace where
      ArrayList resides, see screenshot.

      It says,

      Namespace: System.Collections

      That means you need a 'using' directive, at the
      top of your script, like this,

      using System.Collections;

      Do you have that in your script?

      Answer:
      You probably don't, since the error message
      you're getting is exactly what happens when a
      required using directive is missing.
      Attached Files

      Comment


        #4
        NinjaTrader_BrandonH and bltdavid.

        Thank you both for the help.

        This is what I presently have in Using declarations:

        Code:
        #region Using declarations
        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.ComponentModel.DataAnnotations;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Windows;
        using System.Windows.Input;
        using System.Windows.Media;
        using System.Xml.Serialization;
        using NinjaTrader.Cbi;
        using NinjaTrader.Gui;
        using NinjaTrader.Gui.Chart;
        using NinjaTrader.Gui.SuperDom;
        using NinjaTrader.Gui.Tools;
        using NinjaTrader.Data;
        using NinjaTrader.NinjaScript;
        using NinjaTrader.Core.FloatingPoint;
        using NinjaTrader.NinjaScript.DrawingTools;
        #endregion



        This is the line the compile error is referring to.


        Code:
         private ArrayList latsCollection;
        Does "latscollection" or similar need to be added to the above declaration list ?
        I've tried various combinations ie:

        Code:
        System.latsCollection:
        but i get further compile errors.


        Again my thanks
        Last edited by dj22522; 06-10-2022, 09:51 AM.

        Comment


          #5
          Hello dj22522,

          Thanks for your note.

          As previously stated, you would need to add 'using System.Collections' to the Using Declarations section at the top of your script.

          This is also seen in the publicly available Microsoft Documentation linked in post #2.

          Let us know if we may assist further.
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            Change your code thusly,

            Code:
            #region Using declarations
            using System;
            [B][COLOR=#e74c3c]using System.Collections;[/COLOR][/B]
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.ComponentModel.DataAnnotations;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            using System.Windows;
            using System.Windows.Input;
            using System.Windows.Media;
            using System.Xml.Serialization;
            using NinjaTrader.Cbi;
            using NinjaTrader.Gui;
            using NinjaTrader.Gui.Chart;
            using NinjaTrader.Gui.SuperDom;
            using NinjaTrader.Gui.Tools;
            using NinjaTrader.Data;
            using NinjaTrader.NinjaScript;
            using NinjaTrader.Core.FloatingPoint;
            using NinjaTrader.NinjaScript.DrawingTools;
            #endregion

            Comment


              #7
              Thank you both.

              I've added the line "using System.Collections" to declarations.

              I'm now getting the following error:

              "The name "CheckPennants" does not exist in the current context."


              The CheckPennant referred to in the error message is presently in OnBarUpdate:-

              Code:
              protected override void OnBarUpdate()
              {
              {
              if (CurrentBar < 1) return;
              
              CheckPennants ();
              }
              I'm aware some things need to be moved to OnStateChange for NT8.

              Is this the case here.

              I've tried with ie:

              Code:
              protected override void OnStateChange()
              {
              if (State == State.SetDefaults)
              {
              
              CheckPennants ();
              }
              }

              But the compile error remains:

              "The name "CheckPennants" does not exist in the current context."

              Help appreciated

              Many thanks
              Last edited by dj22522; 06-10-2022, 10:45 AM.

              Comment


                #8
                Hello dj22522,

                Thanks for your note.

                The error: 'The name "__" does not exist in the current context' means that the variable or method you are using does not exist where you are trying to use it.

                The CheckPennants() method seems to be a custom method that might be created in the NinjaTrader 7 script. You would need to also create this method for the NinjaTrader 8 script similar to how it is created in the NinjaTrader 7 script.

                Please review the NinjaTrader 7 script to determine where and how the CheckPennants() variable/method is being created in that script. Then recreate the variable/method in the NinjaTrader 8 script.

                Let us know if we may assist further.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  NinjaTrader_BrandonH

                  Many thanks.

                  Yes the indicator is a custom script written for me for NT7 a while ago.


                  So I've added to the NT8 version those parts from NT7 relating to CheckPennants.

                  It now compiles without error, which is progress.

                  However now nothing the indicator is supposed to display is showing on the chart.


                  Any help welcome.

                  Many thanks
                  Last edited by dj22522; 06-11-2022, 01:17 AM.

                  Comment


                    #10
                    Hello dj22522,

                    Thanks for your note.

                    To understand why the script is behaving as it is, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

                    In the script add prints that print all of the values of every variable used in the script along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

                    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
                    https://ninjatrader.com/support/foru...121#post791121

                    Let us know if we may assist further.
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by dj22522 View Post
                      NinjaTrader_BrandonH

                      Many thanks.

                      Yes the indicator is a custom script written for me for NT7 a while ago.


                      So I've added to the NT8 version those parts from NT7 relating to CheckPennants.

                      It now compiles without error, which is progress.

                      However now nothing the indicator is supposed to display is showing on the chart.


                      Any help welcome.

                      Many thanks

                      NinjaTrader_BrandonH


                      Success:


                      Further to adding the parts relating to CheckPennants from the NT7 to NT8 version and adding the "using System.Collections" declarations I only then needed to increase the Opacity to be higher in NT8 than NT7 version for everything to be displayed on the chart.


                      Many thanks NinjaTrader_BrandonH and bltdavid for your help
                      Last edited by dj22522; 06-11-2022, 01:26 AM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Tim-c, Today, 03:54 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post Tim-c
                      by Tim-c
                       
                      Started by FrancisMorro, Today, 03:24 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post FrancisMorro  
                      Started by Segwin, 05-07-2018, 02:15 PM
                      10 responses
                      1,771 views
                      0 likes
                      Last Post Leafcutter  
                      Started by Rapine Heihei, 04-23-2024, 07:51 PM
                      2 responses
                      31 views
                      0 likes
                      Last Post Max238
                      by Max238
                       
                      Started by Shansen, 08-30-2019, 10:18 PM
                      24 responses
                      945 views
                      0 likes
                      Last Post spwizard  
                      Working...
                      X