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

  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • CDXTrader
    replied
    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.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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" };

    Leave a comment:


  • CDXTrader
    replied
    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

    Leave a comment:


  • gurko
    replied
    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!

    Leave a comment:


  • CDXTrader
    replied
    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

    Leave a comment:


  • gurko
    replied
    Thank you Chelsea,

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

    Kind regards,
    Stefan.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • gurko
    started a topic Can I use the UserData property of class Order?

    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.

Latest Posts

Collapse

Topics Statistics Last Post
Started by zstheorist, Today, 07:52 PM
0 responses
3 views
0 likes
Last Post zstheorist  
Started by pmachiraju, 11-01-2023, 04:46 AM
8 responses
149 views
0 likes
Last Post rehmans
by rehmans
 
Started by mattbsea, Today, 05:44 PM
0 responses
5 views
0 likes
Last Post mattbsea  
Started by RideMe, 04-07-2024, 04:54 PM
6 responses
33 views
0 likes
Last Post RideMe
by RideMe
 
Started by tkaboris, Today, 05:13 PM
0 responses
5 views
0 likes
Last Post tkaboris  
Working...
X