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

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
    Chris L.NinjaTrader Customer Service

    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.
        Chris L.NinjaTrader Customer Service

        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
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by frankthearm, Yesterday, 09:08 AM
            14 responses
            47 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by gentlebenthebear, Today, 01:30 AM
            2 responses
            13 views
            0 likes
            Last Post gentlebenthebear  
            Started by Kaledus, Today, 01:29 PM
            2 responses
            8 views
            0 likes
            Last Post Kaledus
            by Kaledus
             
            Started by PaulMohn, Today, 12:36 PM
            2 responses
            16 views
            0 likes
            Last Post PaulMohn  
            Started by Conceptzx, 10-11-2022, 06:38 AM
            2 responses
            56 views
            0 likes
            Last Post PhillT
            by PhillT
             
            Working...
            X