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

Can I use the UserData property of class Order?

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

    Can I use the UserData property of class Order?

    Hi,

    two questions, please:

    I see an undocumented property named UserData in the Order class. The name seems to suggest I could use it to attach arbitrary data to an order. Is that so?

    Also, there is an OnBehalfOf property (also undocumented). What is the purpose of this property?

    Kind regards,
    Stefan.

    #2
    Hello Stefan,

    I've inquiried with our development about these properties.

    Once I have more information I will update this thread.

    We appreciate your patience.
    Last edited by NinjaTrader_ChelseaB; 10-11-2021, 02:14 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Stefan,

      Our development has given me a response.

      The Order.UserData collection is not indented for use with NinjaScripts and is used for internal tracking from the core of NinjaTrader.

      Modifying this collection can result in unintended behavior.

      Further, the OnBehalfOf property is also used internally, is not intended for use with NinjaScripts and they are not providing information on how this is used internally.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thank you Chelsea,

        fine, I will leave the undocumented fields alone. I can store my order-related data in other ways.

        Kind regards,
        Stefan.

        Comment


          #5
          Hi Stefan,
          I realize this comment is years old but I was wondering did you ever find a suitable way to store custom data for your orders?
          cheers

          Comment


            #6
            Unfortunately, I don't remember. The OrderId field is neither unique nor constant (according to the docs), so it can't be used to safely reference an order. No idea, sorry!

            Comment


              #7
              Understood, thank you anyway Stefan.

              NinjaTrader_ChelseaB
              Since this thread was posted do you guys have any other field or suggestion on how to store and persist my own custom order data to an Order object? One simple string field would do.

              I've tried creating my own class inheriting from the Order class but NT does not recognize it. I've also tried FromEntrySignal but this field does not seem to persist to disk/database automatically. Perhaps there's some static method I can use to persist this field to the database after setting the field?

              As always, any help would be greatly appreciated. Or if you can just point me in the right direction of which class or property to look at, that would be awesome.
              cheers

              Comment


                #8
                Hello CDXTrader,

                There is not a recommend approach to saving other information with an order, but first thoughts that come to mind is a custom class that has an Order object along with the custom field.

                public class MyCustomOrderClass()
                {
                public Order ThisOrder;
                public string MyCustomInfoString;
                }

                new MyCustomOrderClass() { Order = order, MyCustomInfoString = "information I want to save with the order" };
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chelsea, thank you for the reply.
                  Yes, saving an Order object and some custom information along with it is quite a simple endeavor but that does not help me persist that information to disk so the orders are automatically reloaded upon restart. I thought maybe a custom Order property was available that would do the trick. Seems like overkill to create my own file database and read/write/maintain it only for one tiny string. Oh well, appreciate the thought.

                  Comment


                    #10
                    Hello CDXTrader,

                    If you are wanting to write information and read information from a file, you will need custom code that writes those files.

                    You can write to text file with StreamWriter and read from a text file with StreamReader.
                    https://ninjatrader.com/support/help...o_write_to.htm
                    https://ninjatrader.com/support/help...o_read_fro.htm

                    NinjaTrader does not support access to the NinjaTrader database.
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by DJ888, 04-16-2024, 06:09 PM
                    4 responses
                    11 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by terofs, Today, 04:18 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post terofs
                    by terofs
                     
                    Started by nandhumca, Today, 03:41 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post nandhumca  
                    Started by The_Sec, Today, 03:37 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post The_Sec
                    by The_Sec
                     
                    Started by GwFutures1988, Today, 02:48 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Working...
                    X