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

The second index...

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

    The second index...

    Before my interesting Ninja Script, I'd learning C#, And I can't understand one moment in the syntax of language NT7. For example I take this links.
    Here we can see That method Closes has 2 index... What is means?

    1. At first in C# don't use syntax like this:
    Code:
    Closes[0][0]
    Such syntax using only in arrays...

    2. There method Closes has 2 index, but on this page typing about using this method:
    Syntax
    Closes[int barSeriesIndex][int barsAgo]
    What is means this two indexes in square brackets?
    Last edited by hozman; 06-05-2015, 03:12 PM.

    #2
    Closes is a jagged array - https://msdn.microsoft.com/en-us/library/2s05feca.aspx

    It is an array which holds an additional BarsArray, which is used for Multi-Instrument scripting:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Hello hozman,

      Thank you for your inquiry.

      Two indexes means that this variable is an array of arrays or a jagged array.

      You can learn more about jagged here: https://msdn.microsoft.com/en-us/library/2s05feca.aspx

      Closes[int barSeriesIndex][int barsAgo] means:
      • int barSeriesIndex refers to the index of the DataSeries (http://www.ninjatrader.com/support/h...ries_class.htm) object in this Closes array. For example, say you have an indicator that has an Add(PeriodType.Tick, 1) in its Initialize method. A barSeriesIndex value of 0 will access the primary bar (whatever bartype you have selected for the chart). An index value of 1 would access this Tick bartype you just added. If you add more bartypes, the index value will continue on from here (2, 3, 4... etc).
      • int barsAgo will refer to the barsAgo value you would like to access for the current bar index you have selected. So, for example:
        Code:
        Closes[0][0]
        would access the current bar in the primary bartype of your chart.


      Please, let us know if we may be of further assistance!
      Zachary G.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_ZacharyG View Post
        You can learn more about jagged here: https://msdn.microsoft.com/en-us/library/2s05feca.aspx
        Please, let us know if we may be of further assistance!
        I now that is jagged arrays from C#. But I don't understand which sense here from it. Earlie, I wrote on mql4 to MT4 platform. And there syntax to access, for example, to Dataseries Open Price is only:
        Open [i];
        where i - is number of barto history.
        And I'dont understand why in Ninja Script using jagged arrays... Particularly, here us ineresting only price ( Open, Close,Hight..etc ).
        How I can take acces to necessary trading instrument's Open using jagged array?

        Originally posted by NinjaTrader_ZacharyG View Post
        would access the current bar in the primary bartype of your chart.
        What You keep in mind by primary type?

        Comment


          #5
          You only need to use the plural and double array syntax when using Add() to access that stuff. Read the link about multi data series.

          Comment


            #6
            Originally posted by sledge View Post
            You only need to use the plural and double array syntax when using Add() to access that stuff.
            I don't ask about Add().

            Originally posted by sledge View Post
            Read the link about multi data series.
            Where this link ?

            Comment


              #7
              Originally posted by hozman View Post
              I don't ask about Add().
              No, you did not. But you did ask about a syntax that uses two indices. You were being told how that situation arises. Why does that education effort warrant this kind of response, implying that the responder is ignorant, when it is you who does not understand?

              Comment


                #8
                Originally posted by koganam View Post
                No, you did not. But you did ask about a syntax that uses two indices. You were being told how that situation arises. Why does that education effort warrant this kind of response, implying that the responder is ignorant, when it is you who does not understand?
                I don't kind that somebody ignored me, but I am don't not understand english to perfection, because speak Russion And that is the reason for my some misunderstanding...
                But I make efforts for it.

                Comment


                  #9
                  Hello hozman,

                  Using a jagged array requires the use of the Add() method as jagged arrays in NinjaTrader would deal with multi-series scripts.

                  Here is a link to the NinjaTrader help guide dealing with the Add() method in this instance: http://www.ninjatrader.com/support/h....html?add3.htm

                  Here is more information about multi-series scripts: http://www.ninjatrader.com/support/h...nstruments.htm

                  If you do not plan on working with multi-series scripts just yet and plan on working with only one DataSeries, you can access the Close value of the current bar by using Close[0]. There would be no need with using jagged arrays in this case.
                  Zachary G.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by algospoke, Yesterday, 06:40 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post algospoke  
                  Started by ghoul, Today, 06:02 PM
                  3 responses
                  14 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by jeronymite, 04-12-2024, 04:26 PM
                  3 responses
                  45 views
                  0 likes
                  Last Post jeronymite  
                  Started by Barry Milan, Yesterday, 10:35 PM
                  7 responses
                  21 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  10 responses
                  181 views
                  0 likes
                  Last Post jeronymite  
                  Working...
                  X