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

"Array" instead of "Dataseries"

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

    "Array" instead of "Dataseries"

    Hi Ninjas,

    I need to code some loop for calculations and keeping values on a particular one-dimensional array. I've tried to do this with Ninjatrader native-Dataseries but, it doesn't work for my special order index needs.

    So, I'm trying to declare and initialize a simple one-dimensional with LIST or ARRAY , but so far, I must miss some obvious step cause it doesn't work at all. I've read many tutorials and instructions but not solution yet.

    Now I wonder if working with arrays is not possible in Ninjatrader cause it crashes with the Dataseries way to do it.

    Could I actually see a simple example and how to declare and initialize a simple one-dimensional array for integer values ?

    My goal is the following: for each new BarUpdate, I need to do for example 10 different calculations of certain variables, storing each result in a different "Container" ( as a LIST array ) to be able to access them once again in the new coming BarUpdate. Easy.

    Any hints?

    Thanks
    Last edited by pstrusi; 09-07-2015, 02:58 AM.

    #2
    Originally posted by pstrusi View Post
    Hi Ninjas,

    I need to code some loop for calculations and keeping values by the same internal loop order index. I've tried to do this with the Ninjatrader native-Dataseries but since this is special class attached to the numbers of bars, it doesn't work for my special order index needs.

    So, I'm trying to declare and initialize a simple one-dimensional arrays, but so far, I must miss some obvious step cause it doesn't work at all. I've read many tutorials and instructions but not solution yet.

    Now I wonder if working with arrays is not possible in Ninjatrader cause it crash with the Dataseries way to do it.

    Could I actually see a simple example and how to declare and initialize a simple one-dimensional array for integer values ?

    Thanks
    What have you written that you say does not work, and what do you mean by: "doesn't work at all"?

    Comment


      #3
      It's easier to ask you simply how to declare and initialize a simple one-dimensional array for int values that explaining what you ask.

      If you could.....I'd be highly grateful
      Last edited by pstrusi; 09-06-2015, 11:14 AM.

      Comment


        #4
        Originally posted by pstrusi View Post
        It's easier to ask you simply how to declare and initialize a simple one-dimensional array for int values that explaining what you ask.

        If you could.....I'd be highly grateful
        Create and loop over a string array. Access array Length and get elements at indexes.


        Scroll down to "INT"

        Comment


          #5
          Thanks Sledge, but I've already tried that site and many others, but I'm still missing some "configuration" in NT to work properly. Thanks anyway

          Comment


            #6
            Originally posted by pstrusi View Post
            Thanks Sledge, but I've already tried that site and many others, but I'm still missing some "configuration" in NT to work properly. Thanks anyway
            What isn't working?

            Please - post some code that shows it isn't working.

            Comment


              #7
              Originally posted by sledge View Post
              What isn't working?

              Please - post some code that shows it isn't working.

              Code:
                      #region Variables
                      // Wizard generated variables
                          private int myInput0 = 1; // Default setting for MyInput0
                      // User defined variables (add any user defined variables below)
              		int[] array = { -5, -6, -7 };
              
              ...
                      protected override void OnBarUpdate()
                      {
                          // Use this method for calculating your indicator values. Assign a value to each
                          // plot below by replacing 'Close[0]' with your own formula.
                          //Plot0.Set(Close[0]);
               
              			Print ( "array[0]= " + array[0] );

              Comment


                #8
                Thanks for your time, suggestions and ideas to try out later, actually I'm under heavy backtesting in other Algo.

                Thanks

                Comment


                  #9
                  If it's something we can focus in on - compilation errors (.net problems?) or logic based - initialization - static/dynamic arrays - copying - looping - performing computations from...

                  Comment


                    #10
                    Originally posted by sledge View Post
                    What isn't working?

                    Please - post some code that shows it isn't working.
                    Which, I might point out, is what I asked in the first place!

                    Comment


                      #11
                      Definitively Logic.based, the most probable :

                      Declaring, initialization - static/dynamic arrays..

                      I've tried LISTS and ARRAYS. They seems pretty simple to put them at work, but something in the Scrip prevent it to work right.

                      The logic code that works is not the reason, cause it's a simple For-loop.

                      Comment


                        #12
                        Koganam you've help me a lot in past situations, no doubt you know deep level, but believe me, this situation is not about the simple loop, it's about how to be able to use it properly a LIST or ARRAY, that's all :-)

                        Comment


                          #13
                          Originally posted by pstrusi View Post
                          Koganam you've help me a lot in past situations, no doubt you know deep level, but believe me, this situation is not about the simple loop, it's about how to be able to use it properly a LIST or ARRAY, that's all :-)
                          I use Lists and ArrayLists in many of my commercial indicators, but unless I can see the way that you are trying to use the code, I am not sure that I am in a position to help. I understand that you think you know what the problem is, but do you really? Initializing an array is a standard C# thing, so if it is not working out the way that you are doing it, then that is the issue.

                          If we see it, we can show you what is wrong, and how to correct it. That gives you more information that me trying to show you something which may not even be suitable for what you want to do. But, if that is the actual secret sauce, then it makes sense that you would rather not disclose it. I might point out that this thread is now 4 hours long. Has that really been a good use of your time?

                          Comment


                            #14
                            After seeing practical cases for better results, I think that using LIST would help me to work properly with one-dimensional arrays.

                            Please, any of NT team support:

                            Could you simply tell me, how to declaret and initialize a simple LIST array ?

                            1. Starting with this, I know that you must add to the code this declaration:
                            using System.Collections.Generic;

                            2.After that, where to put this in order to work properly with OnBarUpdate?
                            List<int> myInts = new List<int>();
                            After, before or within at protected override void Initialize()?
                            After, before or within at protected override void OnBarUpdate()

                            I've tried every combination but something is missing

                            Thanks
                            Last edited by pstrusi; 09-06-2015, 11:54 PM.

                            Comment


                              #15
                              Originally posted by koganam View Post
                              But, if that is the actual secret sauce, then it makes sense that you would rather not disclose it. I might point out that this thread is now 4 hours long. Has that really been a good use of your time?
                              I think he's asleep at the moment as it is past OUR bedtimes... :zzzz

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by kempotrader, Today, 08:56 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post kempotrader  
                              Started by kempotrader, Today, 08:54 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post kempotrader  
                              Started by mmenigma, Today, 08:54 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post mmenigma  
                              Started by halgo_boulder, Today, 08:44 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post halgo_boulder  
                              Started by drewski1980, Today, 08:24 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post drewski1980  
                              Working...
                              X