• 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

Array with string and double for sorting

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

    Array with string and double for sorting

    I am new at NT programming, so this is fairly basic.
    What I want to do is read into the array five different moving averages, etc. and their different types. Example 20 SMA, LinReg 9 and so on. This requires 2D array which holds the string "Type" and double "Value". I then want to sort them from the lowest to highest for further processing. My question is what is the easiest way to do this? Could I use the List method or would I need to use the Sort().

    #2
    Hello profitsareking,
    Welcome to the forum and I am happy to assist you.

    You can also use a sortedlist to do it. Please refer to the below link to know more about it
    http://msdn.microsoft.com/en-us/libr...ortedlist.aspx
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Originally posted by profitsareking View Post
      I am new at NT programming, so this is fairly basic.
      What I want to do is read into the array five different moving averages, etc. and their different types. Example 20 SMA, LinReg 9 and so on. This requires 2D array which holds the string "Type" and double "Value". I then want to sort them from the lowest to highest for further processing. My question is what is the easiest way to do this? Could I use the List method or would I need to use the Sort().
      Use a SortedDictionary.

      ref: http://msdn.microsoft.com/en-us/library/f7fta44c.aspx
      Last edited by koganam; 01-16-2013, 04:02 PM.

      Comment


        #4
        Hi and thanks to both NinjaTrader_Joydeep and koganam.
        I decided to use SortedList since SortedDisctionary requires all unique keys else throws an exception. Since, in a rare case, two moving averages could have the same value when crossing, this would require exception handling which complicates things.

        I decided to use the sample at http://msdn.microsoft.com/en-us/library/cxb97few.aspx

        I am getting compile error:

        The type or namespace name 'SortedList' could not be found (are you missing a using directive or an assembly reference?)

        Can you give me quick heads up what is that about? Many thanks

        Comment


          #5
          Hello profitsareking,
          Please make sure you are using the below declaration if you decide to use any generic collection.

          Code:
          using System.Collections.Generic;
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            I still get the same error and in addition I get:

            Using the generic type 'System.Collections.Generic.SortedList<TKey,TValue >' requires '2' type arguments

            Comment


              #7
              Hello profitsa,reking
              To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

              Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

              I look forward to assisting you further.

              *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
              JoydeepNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by tecmisc1, Today, 09:57 AM
              0 responses
              2 views
              0 likes
              Last Post tecmisc1  
              Started by mbesha, Today, 09:26 AM
              0 responses
              1 view
              0 likes
              Last Post mbesha
              by mbesha
               
              Started by Brillo, Today, 08:58 AM
              0 responses
              6 views
              0 likes
              Last Post Brillo
              by Brillo
               
              Started by avrege, Today, 01:48 AM
              2 responses
              13 views
              0 likes
              Last Post avrege
              by avrege
               
              Started by markbb10, Today, 07:14 AM
              0 responses
              7 views
              0 likes
              Last Post markbb10  
              Working...
              X