Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on Executing DB Command

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

    Error on Executing DB Command

    I am getting the error below when I have my strategy activated.
    It appears in the log about every 10 seconds.
    The strategy itself works fine.

    I have no idea to track this error down.

    At first I thought it might be in relation to my exit orders.
    I was trying to code to exit all positions with the exit itself named.

    ExitLong(Convert.ToInt32(Position.Quantity), @"BreakEven Lx", Convert.ToString(""));

    For debugging purposes I inserted
    ExitLong();

    Still receiving error.
    7/4/2021 10:55:46 AM DB Error on executing DB command: System.Data.SqlServerCe.SqlCeException (0x80004005): A duplicate value cannot be inserted into a unique index. [ Table name = Orders,Constraint name = PK__Orders__000000000000033E ] at System.Data.SqlServerCe.SqlCeCommand.ProcessResult s(Int32 hr) at System.Data.SqlServerCe.SqlCeCommand.ExecuteComman dText(IntPtr& pCursor, Boolean& isBaseTableCursor) at System.Data.SqlServerCe.SqlCeCommand.ExecuteComman d(CommandBehavior behavior, String method, ResultSetOptions options) at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQue ry() at NinjaTrader.Cbi.Order.DbAdd() at NinjaTrader.Cbi.DB.DBThread()

    #2
    Hi sdauteuil, thanks for writing in.

    This is coming from the database file in Documents/NinjaTrader 8. If this continues to happen, you might need to selectively remove third party addons if you have any. For now please reset your database file:
    • Disconnect NinjaTrader from any open connections via Connections > Disconnect
    • From the NinjaTrader Control Center window select the menu Tools > Database Management
    • Press "Reset DB"
    • Check Historical Orders to remove historical orders
    • Check Historical Trades to remove historical trades
    • Press the "Reset" button
    Best regards,
    -ChrisL

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      "Reset DB"
      Does this mean NT is gonna delete historical data (tick, minute etc)?

      Comment


        #4
        Hi Leeroy, thanks for posting.

        Yes, the historical data would be removed from this action.

        Comment


          #5
          Is there any way I can fix this log error w/o losing my historical data?

          Comment


            #6
            Hi Leeroy,

            The historical data will only be removed id you check "remove historical data". With out that checked, it will only reset the database file which would resolve this database error.

            Best regards,
            -ChrisL

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            45 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            21 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            31 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            50 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Working...
            X