Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

System.Data.SqlServerCe.SqlCeException

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

    System.Data.SqlServerCe.SqlCeException

    Hello,

    I am getting this exception that stops my strategy.


    2017-08-29 12:50:34:583 ERROR: Error on executing DB command: System.Data.SqlServerCe.SqlCeException (0x80004005): A foreign key value cannot be inserted because a corresponding primary key value does not exist. [ Foreign key constraint name = FK__Strategy2Order__0000000000000403 ] 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.NinjaScript.StrategyBase.DbAdd() at NinjaTrader.NinjaScript.StrategyBase.DbUpdate() at NinjaTrader.Cbi.DB.DBThread()

    #2
    Hello cls71,

    The error indicates corruption in the database file. To resolve this error, please create a new database by renaming your existing database.

    - Shutdown NinjaTrader and go to the Windows Start Menu
    - Select Documents-->NinjaTrader 8-->db--> NinjaTrader.sdf file (SQL Server Compact Edition Database File)
    - Right click on the NinjaTrader database file and select "Rename". Name it "OLDNinjaTrader".
    - Then restart the software and NinjaTrader will create a fresh database file to use

    Unfortunately the following items stored in the old database will be lost - Trading Hours templates, Instrument Lists/Custom Instruments, historical trade execution data, saved Strategy Analyzer backtest results.

    To prevent running into situations where you can potentially lose important data, we advise running regular backups via our inbuilt backup feature in NinjaTrader - http://ninjatrader.com/support/helpG...up_archive.htm
    JasonNinjaTrader Customer Service

    Comment


      #3
      Hello,

      this error continues happening very often. It is easy to test it in the Sim101 account.

      1.- Load this strategy in 10 seconds.

      Code:
      protected override void OnBarUpdate()
      		{
      			if( State == State.Historical )
      				return;
      			
      			EnterShortLimit( High[0] + 80 * TickSize, "Mi Venta-" + CurrentBar );
      		}
      2.- Let the strategy work for a couple of minutes.
      3.- Deactivate the strategy from the Strategies tab, Reset the Sim101 account (from the Accounts tab, right click on Sim101 / Edit Account... and clic on Reset, to delete the historical.
      4.- Activate the strategy again from Strategies tab.

      And so on several times until the error appears (it does not take long).

      Thanks

      Comment


        #4
        Hello cls71,

        Thanks for the test case and the steps.

        I have done as instructed on my end and I have not hit the error you are encountering. I have also enabled the strategy against a 5 second and 3 second data series in addition to the 10 second data series to try and hit the issue, but without success.

        We have just released a new version of NinjaTrader 8. Could you test the new version (R12) to see if you can still hit the issue?

        Updates for NinjaTrader can be downloaded here: https://ninjatrader.com/PlatformDirect

        If you are still able to hit the issue after updating, our next step will be to test again in a clean environment. Creating a clean environment can be done by following the steps below:

        1. Close NinjaTrader 8, and rename the "NinjaTrader 8" folder in My Documents to something like: "NinjaTrader 8 OLD"
        2. Uninstall NinjaTrader from the Windows Control Panel and reinstall using the installer from http://ninjatrader.com/PlatformDirect
        3. Add your AddOns to your new platform in groups and test until the issue arises. Once the issues arises, remove the last group and test those AddOns individually.

        If you ever need to switch back to your original platform, you may do so by closing NinjaTrader and swapping the platform folder names. For example, Close NinjaTrader and rename the new "NinjaTrader 8" folder to "NinjaTrader 8 NEW" and the "NinjaTrader 8 OLD" folder to "NinjaTrader 8." Then restart the platform. Simply put: NinjaTrader 8 will always load the "NinjaTrader 8" folder in My Documents.

        Please let me know the results of these tests.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,602 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        8 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        4 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        12 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X