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

receiving error on executing DB command

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

    receiving error on executing DB command

    Hello, I am working on a strategy and testing on playback, I haven't had this error come up before and I don't understand what it means. The full error copied is as follows:

    Error on executing DB command: code = Constraint (19), message = System.Data.SQLite.SQLiteException (0x800027AF): constraint failed FOREIGN KEY constraint failed at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt) at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt) at System.Data.SQLite.SQLiteDataReader.NextResult() at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCo mmand cmd, CommandBehavior behave) at System.Data.SQLite.SQLiteCommand.ExecuteReader(Com mandBehavior behavior) at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery(C ommandBehavior behavior) at NinjaTrader.NinjaScript.StrategyBase.DbAdd() at NinjaTrader.Cbi.DB.DBThread()

    I don't think I've added anything to the code that would be accessing a database I haven't already been using. I have 1 minute dataseries and tick dataseries added for NQ that has already been working fine before now.

    #2
    Hello somethingcomplex,

    Thank you for your post.

    The Playback101 account that trades are submitted to when connected to the Playback connection is based on the properties of the Sim101 account which is stored in the NinjaTrader.sqlite database file. First, I suggest resetting your Sim101 account and then testing for this error. To manage, edit, or reset your Sim101 account, do the following:
    • Disconnect from the Playback connection
    • Go to the Control Center > Accounts window
    • Right-click on the Sim101 account > select 'Edit Account'
    • In this window, you may change the Initial Cash Size for your Sim101 account, as well as add other features such as Commissions and Risk Templates
    • To apply the changes, click on the 'reset' button at the bottom of the window. You may need to restart the platform for these changes to take full effect.
    • Reconnect to Playback and test
    If the error persists, then the error might be caused by another item in your database. If that is the case, you can try renaming your database. You may rename your database to resolve this item using the following steps:
    • Shutdown NinjaTrader, and navigate to the Windows File Explorer (Windows Key + E)
    • Go to the Documents/NinjaTrader 8/db folder
    • Right-click on "NinjaTrader.sqlite" and rename it to "NinjaTrader OLD.sqlite"
    • When you restart NinjaTrader, a fresh database file will automatically be created by the software.
    • Unfortunately, the following items stored in the old database will be lost - custom Trading Hours templates, custom Instruments/Instrument Lists, historical trade execution data, and saved Strategy Analyzer backtest results
    To prevent running into situations where you can potentially lose important data, we advise running regular backups via the built-in Backup feature in NinjaTrader.

    Please let us know if we can be of further assistance.


    Emily C.NinjaTrader Customer Service

    Comment


      #3
      When you say custom instruments will be lost, will the strategy I'm working on be gone? I can export it as a ninja script add on and then reload it with the new database correct? Also the link to the backup page takes me to the ninjatrader website but says page not found. Also I was wondering, I don't get the database error when I run it with the previous stops and targets I was using, only when I run the new stuff I'm testing. Would that still be congruent with a database error of this sort?

      Comment


        #4
        Originally posted by somethingcomplex View Post
        When you say custom instruments will be lost, will the strategy I'm working on be gone? I can export it as a ninja script add on and then reload it with the new database correct? Also the link to the backup page takes me to the ninjatrader website but says page not found. Also I was wondering, I don't get the database error when I run it with the previous stops and targets I was using, only when I run the new stuff I'm testing. Would that still be congruent with a database error of this sort?
        No; the strategy will not be lost. Only custom instruments that have been added to the Control Center > Tools > Instruments window would be lost:


        More information about the backup and restore functions may be found in the help guide here:


        Although you have only seen this since testing new stuff, it does seem to be related to the NinjaTrader.sqlite database file. You could always test by renaming the file, and if for any reason you need to revert to your previous database file you may shut down NinjaTrader, add "NEW" to the new database file name, and remove "OLD" from the previous database file. Then, when you launch NinjaTrader again it will be using the previous file (although this could cause the errors and unexpected behavior to return).

        Thank you for your time and patience.
        Emily C.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, Today, 10:57 PM
        0 responses
        6 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        158 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Today, 09:29 PM
        0 responses
        7 views
        0 likes
        Last Post Belfortbucks  
        Started by zstheorist, Today, 07:52 PM
        0 responses
        7 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        151 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Working...
        X