Announcement

Collapse
No announcement yet.

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);

    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

        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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            571 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            330 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            549 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            549 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X