Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Classes and Lists of Objects

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

    Custom Classes and Lists of Objects

    I am curious, being able to track submitted orders (IOrder objects), in a list in a structured format is rather simple (conceptually), however, doesn't seem to work nicely here in NT. For example, from my experience with C# and MVC, I can do something like this:

    Code:
    public class APosition
    {
            public IOrder Entry { get; set; }
            public IOrder Target { get; set; }
            public IOrder Stop { get; set; }
            public int EntryId { get; set; }
            public Pro9Position() {}
    }
    
    APosition MyPositions = new List<APosition>();
    Which, of course, compiles without issue. And, when I submit orders I can actually add to my list with the necessary IOrder object, and all is well.

    However, when I try to enable this for strategies, etc, I of course, receive Serialization errors, due to the fact that IOrder is an interface.

    If I change it to 'Order', which technically isn't supported, and cast the SubmitOrder() methods to (Order), it also compiles without issue, but the Serialization errors crop up stating that Order.Account.Connection isn't serializeable due to the fact that Order.Account.Connection doesn't implement IConnection.

    Thus to me, it seems like we cannot have a LIST object of orders that we can quickly query and track.

    Is this correct?

    #2
    Originally posted by zackrspv View Post
    However, when I try to enable this for strategies, etc, I of course, receive Serialization errors, due to the fact that IOrder is an interface.
    Make the APosition class private?

    Comment


      #3
      Is MyPositions public or private?
      Is it declared inside your Strategy based class?

      Ultimately, what you need to do is tell the serializer to ignore the public property/variable that it is attempting to serialize.

      You'll do that by making it private (instead of public) or by adding [XmlIgnore()] attribute to the variable or property.

      Comment


        #4
        Originally posted by zackrspv View Post
        I am curious, being able to track submitted orders (IOrder objects), in a list in a structured format is rather simple (conceptually), however, doesn't seem to work nicely here in NT. For example, from my experience with C# and MVC, I can do something like this:

        Code:
        public class APosition
        {
                public IOrder Entry { get; set; }
                public IOrder Target { get; set; }
                public IOrder Stop { get; set; }
                public int EntryId { get; set; }
                public Pro9Position() {}
        }
        
        APosition MyPositions = new List<APosition>();
        Which, of course, compiles without issue. And, when I submit orders I can actually add to my list with the necessary IOrder object, and all is well.

        However, when I try to enable this for strategies, etc, I of course, receive Serialization errors, due to the fact that IOrder is an interface.

        If I change it to 'Order', which technically isn't supported, and cast the SubmitOrder() methods to (Order), it also compiles without issue, but the Serialization errors crop up stating that Order.Account.Connection isn't serializeable due to the fact that Order.Account.Connection doesn't implement IConnection.

        Thus to me, it seems like we cannot have a LIST object of orders that we can quickly query and track.

        Is this correct?
        Are you trying to serialize APosition objects?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X