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

primary key value does not exist

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

    primary key value does not exist

    Any idea what this is about?

    this is in my initialize
    SetProfitTarget(CalculationMode.Ticks, target);
    SetStopLoss(CalculationMode.Ticks, stop);


    2011-03-11 11:36:38:906 Db.Globals.StrategyUpdateJob2: WARNING: Execution='f5aeb0ee365c49cc8f85ab7998906b24' Instrument='ES 03-11' Account='AutoTrade' Name='Short' Exchange=Default Price=1296.5 Quantity=1 Market position=Short Commission=2.5 Order='e0051ce2948241179af5ef05463b6aac' Time='3/10/2011 10:07:16 AM'
    2011-03-11 11:36:38:906 Db.Globals.StrategyUpdateJob2: WARNING: Execution='a42b8ab76a484c42ac50535fdd412219' Instrument='ES 03-11' Account='AutoTrade' Name='Trail' Exchange=Default Price=1303.5 Quantity=1 Market position=Long Commission=2.5 Order='52db3bbc9bd9464592c952295728bf0a' Time='3/10/2011 12:00:02 PM'
    2011-03-11 11:36:39:236 Failed to execute DB job 'StrategyUpdateJob': A foreign key value cannot be inserted because a corresponding primary key value does not exist. [ Foreign key constraint name = FK__nt_strategy2execution__000000000000028B ]
    Last edited by gg80108; 03-11-2011, 11:08 AM. Reason: added info

    #2
    Hello gg80108,

    First step with database issues is to run a repair.

    Please follow the instructions below to repair the NinjaTrader database.

    * Disconnect NinjaTrader from any open connections via File > Disconnect
    * From the NinjaTrader Control Center window select the menu Tools > Options
    * Select the "Data" tab
    * Press the "Repair DB" button
    * Press the "OK" button

    Let us know if you're still seeing that message after running a repair.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I have similar error.
      I do a "repair DB" but return the same error:
      Failed to execute DB job 'StrategyUpdateJob': A foreign key value cannot be inserted because a corresponding primary key value does not exist. [ Foreign key constraint name = FK__nt_strategy__0000000000000277 ]

      Is possible with reference "....277" know the name the strategy that cause error?

      Thanks

      Comment


        #4
        Hello jmagaia,

        Thank you for writing in.

        Please follow the instructions below to reset the NinjaTrader database. (This can take long depending on the size of your database file and your system.)
        • Disconnect NinjaTrader from any open connections via File > Disconnect.
        • From the NinjaTrader Control Center window select the menu Tools > Options.
        • Select the 'Data' tab.
        • Press the 'Reset DB' button.
        • Press the 'OK' button.


        The following data will be removed.
        • Historical orders.
        • Historical executions.
        • Historical ATM strategy data.
        • Saved Strategy Analyzer backtest results.


        The following data will be maintained.
        • ATM strategy templates.
        • Historical chart data.


        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ZacharyG View Post
          Hello jmagaia,

          Thank you for writing in.

          Please follow the instructions below to reset the NinjaTrader database. (This can take long depending on the size of your database file and your system.)
          • Disconnect NinjaTrader from any open connections via File > Disconnect.
          • From the NinjaTrader Control Center window select the menu Tools > Options.
          • Select the 'Data' tab.
          • Press the 'Reset DB' button.
          • Press the 'OK' button.


          The following data will be removed.
          • Historical orders.
          • Historical executions.
          • Historical ATM strategy data.
          • Saved Strategy Analyzer backtest results.


          The following data will be maintained.
          • ATM strategy templates.
          • Historical chart data.


          Please, let us know if we may be of further assistance.
          Well... my strategies included in Workspaces are deleted.

          Now when I load the Workspace the strategies not appear.

          So, I do not know if the problem is resolved. But I come said something when I have to do again the strategies.

          It is not possible, in next time not deleted the strategies when do a reset in DB?
          Or it is not possible load this Strategies in some file?

          thanks

          Comment


            #6
            Hello jmagaia,

            The strategies have not been deleted entirely; they were only removed from the Strategies tab.

            Resetting the database will remove the strategies from the Strategies tab.

            You will need to re-add them again through the Strategies tab or from a chart.
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ZacharyG View Post
              Hello jmagaia,

              The strategies have not been deleted entirely; they were only removed from the Strategies tab.

              Resetting the database will remove the strategies from the Strategies tab.

              You will need to re-add them again through the Strategies tab or from a chart.
              My english... I know that the strategies not deleted...
              But the strategies in tab, how you say, gone...

              Where this information is saved?
              Is is not possible restore?
              They are saved in DB?

              There are some strategies are only open with some WorkSpaces...
              Because In some workspace I have some strategies with some parameters that I do not saved...

              Comment


                #8
                Hello jmagaia,

                The strategy instances were contained within the database. You will need to re-add the strategies in the Strategies tab or a chart.

                If you wish to save the parameters you have set for a strategy to a template, you can do so. To do this, change the strategy parameters to your liking, then right-click within the parameters. You will see a menu with the choice of "Save Default For [strategy name]". When you click on this, the next time you add a new instance of this particular strategy, the parameters you have set as default will be automatically filled.

                I would suggest making a backup of your database once you have set up everything so you can restore to the backup if the issue returns.

                I have provided a link below to our Help Guide that goes over backing up and restoring.

                Zachary G.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks ZacharyG

                  But I also I found (search last night this forum) that the file "NinjaTrader.sdf" have the strategies templates I put again... and of course the problems persist.
                  But I thought there a error with a ticker ... problem with Interactive Brokers using | ... and I put the i upper -. wrong...
                  I delete the strategy that have this problem... but the problem persist.
                  I will try found the problem.... if not...
                  meanwhile I know better how restore some info.

                  I will try discover and fix and not reset... if not... I will reset again...and put all strategies...

                  Comment


                    #10
                    Hello jmagaia,

                    Default strategy templates are stored within the (My) Documents\NinjaTrader 7\templates\Strategy folder on your computer.
                    Zachary G.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_ZacharyG View Post
                      Hello jmagaia,

                      Default strategy templates are stored within the (My) Documents\NinjaTrader 7\templates\Strategy folder on your computer.
                      Default, but the same strategy with diferente parameters are in file that i write

                      And when you say:
                      "The following data will be removed.
                      ...
                      Historical ATM strategy data."

                      If I put the file "NinjaTrader.sdf" again that I has savefd in other location and the "Historical ATM strategy." is restore. That is I want, because I do not put by default some parameters, because the same strategy have differente parameters in same Ticker... for me.

                      I thinbk there are some words not correct by me, but I think the idea is here what I write.
                      But thnaks for the alert.

                      Comment


                        #12
                        Hello jmagaia,

                        ATM (Advanced Trade Management) Strategies and automated NinjaScript strategies are two different things.

                        Can you please clarify if you are speaking of ATM Strategies or NinjaScript strategies?
                        Zachary G.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_ZacharyG View Post
                          Hello jmagaia,

                          ATM (Advanced Trade Management) Strategies and automated NinjaScript strategies are two different things.

                          Can you please clarify if you are speaking of ATM Strategies or NinjaScript strategies?
                          ATM Strategies

                          I know my english not good,, but I think here was I want to do:
                          And when you say:
                          "The following data will be removed.
                          ...
                          Historical ATM strategy data."

                          If I put the file "NinjaTrader.sdf" again that I has savefd in other location and the "Historical ATM strategy." is restore. That is I want, because I do not put by default some parameters, because the same strategy have differente parameters in same Ticker... for me.
                          I want back my strategies when I load a Workspaces, and with Reset all are clear.
                          So to bring back I have restore the file *.sdf

                          Of course I want eliminate the error:
                          Failed to execute DB job 'StrategyUpdateJob': A foreign key value cannot be inserted because a corresponding primary key value does not exist. [ Foreign key constraint name = FK__nt_strategy__0000000000000277 ]
                          But do a Reset to DB resolved the problem, but I do not want do this:
                          " You will need to re-add the strategies in the Strategies tab or a chart."
                          Because I stay in test form, and there are many strategies.
                          So, I try other ways to resolve my problem.

                          There are other ways or not to resolve my problem?
                          thanks

                          Comment


                            #14
                            Hello jmagaia,

                            Historical ATM strategy data is contained within the database.

                            Unfortunately, the error is due to a corrupted database and the only way to resolve the error is to reset the database.

                            I would suggest making a backup of your database once you have set up everything so you can restore to the backup if the issue returns.

                            I have provided a link below to our Help Guide that goes over backing up and restoring.



                            ATM Strategy templates should still be maintained within the ATM Strategy dropdown menu after a database reset. Do your ATM Strategy templates no longer exist?
                            Zachary G.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ZacharyG View Post
                              Hello jmagaia,
                              ...

                              ATM Strategy templates should still be maintained within the ATM Strategy dropdown menu after a database reset. Do your ATM Strategy templates no longer exist?
                              My problem:
                              After Reset DB if I load some Workspaces that have strategies with in, after reset not appear in tab "Strategies"!
                              So, you say it is possible appear, how?

                              What you mean with "ATM Strategy dropdown menu "? Whre I find this after reset DB? Or is in chart i choose strategies ...? If is this of course... not want how explain.

                              thanks

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by andrewtrades, Today, 04:57 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by chbruno, Today, 04:10 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by josh18955, 03-25-2023, 11:16 AM
                              6 responses
                              436 views
                              0 likes
                              Last Post Delerium  
                              Started by FAQtrader, Today, 03:35 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post FAQtrader  
                              Started by rocketman7, Today, 09:41 AM
                              5 responses
                              19 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X