Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Account.CreateOrder with names longer then 50 characters results in strange errors.

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

    Account.CreateOrder with names longer then 50 characters results in strange errors.

    The documentation clearly states that order names should not be longer than 50 characters. This important detail can easily be overlooked if the names for orders are generated at runtime.

    If you create an order with a name longer than 50 characters you will see error messages such as

    "Error on executing DB command: System.Data.SqlServerCe.SqlCeException (0x80004005): A duplicate value cannot be inserted into a unique index. [ Table name = Executions,Constraint name = PK__Executions__0000000000000300"

    in the logs and you'll see more detailed information in the trace file. Unfortunately none of this information makes it clear what exactly has gone wrong.

    It would be great if the Account.CreateOrder function threw an exception if an order name is longer than 50 characters. I strongly suggest anyone using this API to use this extension method instead

    Code:
    public static class AccountExtensions
    {
        public static Order CreateOrderWithChecks(this Account account,
            Instrument instrument,
            OrderAction action,
            OrderType orderType,
            OrderEntry orderEntry,
            TimeInForce timeInForce,
            int quantity,
            double limitPrice,
            double stopPrice,
            string oco,
            string name,
            DateTime gtd,
            CustomOrder customOrder)
        {
            Debug.Assert(name.Length <= 50, "The name is not allowed to be longer than 50 characters.");
            if(name.Length > 50)
            {
                throw new ArgumentException(string.Format("'{0}' order name exceeds 50 characters. Found {1}", name, name.Length));
            }
    
            return account.CreateOrder(instrument,
                action,
                orderType,
                orderEntry,
                timeInForce,
                quantity,
                limitPrice,
                stopPrice,
                oco,
                name,
                gtd,
                customOrder);
        }
    }

    #2
    Hello ntbone,

    I will submit a feature request for Account.CreateOrder function to throw an exception if the order.Name is greater than 50 characters.

    Once I have a tracking ID for this request I will post in this thread for future reference.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you. Similarly I'd suggest the managed/unmanaged strategy functions that accept a name for the order also throw exceptions, if they don't already. I haven't worked directly with those yet so I am not sure if this issue also affects them.

      Comment


        #4
        Hello ntbone,

        I have received tracking ID# SFT-4094 for this request for Account.CreateOrder function to throw an exception if the order.Name is greater than 50 characters.

        Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.

        We appreciate you taking the time to provide feedback.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 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
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        549 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X