Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IOrder objects in array

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

    IOrder objects in array

    In the NT7 help documentation about the IOrder object the example uses a single entryorder which is declared in the variable section:

    Code:
    [COLOR=blue]private[/COLOR] IOrder myEntryOrder = [COLOR=blue]null[/COLOR];
    If my strategy would have for example 10 different entry orders, I would like to group these in an array so each orderstate can be checked more easily in a for..loop

    analog to the creation of a one dimensional array of integers:
    Code:
    [COLOR=blue]int[/COLOR][] xyz = [COLOR=blue]new int[/COLOR][3] {0,0,0};
    I've tried this to create the array of IOrder objects like this, but this doesn't seem to work.
    Code:
     
    [COLOR=blue]pri[/COLOR][COLOR=blue]vate[/COLOR] IOrder[] myEntryOrder = [COLOR=blue]new[/COLOR] IOrder[3]{[COLOR=blue]null,null,null[/COLOR]};
    My questions would be :
    1) Is it possible to create an array of IOrder objects (because the IOrder is a dynamic object, I can imagine it goes wrong in an array) ?
    2) How should this array be declared correctly, if possible ?

    #2
    Hello marcow,

    Thank you for your post.

    Arrays in NinjaScript are more geared toward general C# programming. However, you can find useful information on this topic from several of our users posts. For example the following link provides insight on using arrays:http://www.ninjatrader.com/support/f...ad.php?t=51845

    Comment


      #3
      Patrick,

      I am familiar with creating "regular" arrays in Ninjascript. However those are arrays of integers or doubles not arrays of IOrder objects. My question would be if it is possible to store IOrder objects in an array so that I get IOrder myEntryOrder[1], IOrder myEntryOrder[2], IOrder myEntryOrder[3] and so on ?

      Also, would storing an IOrder object in an array still allow it to function properly ?

      Marco

      Comment


        #4
        Hello marcow,

        Thank you for your response.

        I am not sure if this is possible or not. You are in an unsupported area of NinjaScript.

        You may need to use a string instead and convert it but I am not sure how this would exactly work together. Have you looked into using a list instead? http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

        Comment


          #5
          hello Patrick,

          in the meantime I've been tweaking my strategy code a bit, and the array of IOrder objects seems to work as it should, I declared the IOrder object array like this:
          Code:
           
          private IOrder[] myEntryOrder = new IOrder[3]{null,null,null};
          Yes, a List would certainly be another option, I've been thinking of that also but went for the array because of its fixed length. But now as you mention List again I'm leaning towards the List option because List lenght (List.Count) gives the the number of entries (ie. filled orders)

          Anyway, I now have two options, so at least one should be working...
          Thank you for your support !

          Marco

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X