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

MultiSeries Crash Issue Outside Bounds of Array

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

    MultiSeries Crash Issue Outside Bounds of Array

    Hi Guys, I am trying to run a multiseries strategy and am getting the following 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_strategy2instrument_00000000000002A2]. Also the error in the log says Error on calling onbarupdate method for strategy: Index was outside the bounds of the array.

    I have just done a complete rebuild of ninjatrader only installing the bare minimum of what I need so is running well but not with this strategy. This error occurs the moment I run this line:

    protected override void Initialize()
    {
    AddRenko("", 20, MarketDataType.Last);

    Rest of code is:

    protected override void OnBarUpdate()

    if (BarsInProgress == 1)
    return;

    if (EMA(BarsArray[1],8)[0] > EMA(BarsArray[1],18)[0])

    etc etc

    I'm not sure what the issue is. As mention the moment I put in the AddRenko bit and compile I get the error.

    Any ideas on this odd duck?

    Thanks
    DJ

    #2
    DJ, you would have to specify an instrument to add, you only have an empty string here ("").

    Please try for example :

    AddRenko("ES 03-11", 20, MarketDataType.Last);
    BertrandNinjaTrader Customer Service

    Comment


      #3
      COB False issues and Cancel Strategy

      Thanks Bertrand. I should have know that. I thought that if you included it on say a TF chart it would automatically be included on the latest chart.

      The other issue in respect of this is I am invoking an ATM using COBC = False. Now what I am trying to do is stop the strategy once the first trade has been completed (either stopped out or targets met). Currently it keeps going an I have to manually stop it otherwise it will keep firing off orders.

      Is there a function that says something like "Cancelcurrentstrategy"

      Thanks
      DJ

      Comment


        #4
        You're welcome DJ, you could simply call AtmStrategyClose to shutdown the running strategy and flatten it's position - http://www.ninjatrader.com/support/h...ategyclose.htm
        BertrandNinjaTrader Customer Service

        Comment


          #5
          ATM Strategy Close

          Hi Bertrand, yes I did look at this.

          AtmStrategyClose("idValue");

          What I do is use a different strategy on charts for each of the following instruments:

          - NQ, 6E,CL, TF

          So the question is does this command turn the strategy off completely ie: change the enabled on the chart to false.

          Thanks
          DJ

          Comment


            #6
            DJ, AtmStrategyClose() will only close the specified ATM strategy opened by your regular strategy. It will not shut down (disable) your regular strategy.
            AustinNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bmartz, Today, 09:30 AM
            2 responses
            11 views
            0 likes
            Last Post bltdavid  
            Started by f.saeidi, Today, 11:02 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by geotrades1, Today, 10:02 AM
            4 responses
            12 views
            0 likes
            Last Post geotrades1  
            Started by rajendrasubedi2023, Today, 09:50 AM
            3 responses
            16 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by lorem, Today, 09:18 AM
            2 responses
            11 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X