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

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 burtoninlondon, Today, 12:38 AM
          0 responses
          4 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          12 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          11 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          13 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,982 views
          3 likes
          Last Post jhudas88  
          Working...
          X