Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Scriptstrategies - reset for data?

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

    Scriptstrategies - reset for data?

    Hello,

    my script strategies do correct entries, trade management and exits. But after exits it occurs that new entries are not done - even when conditions are true.

    I have no idea why this occurs. Is there anything to reset maybe somewhere in the script to avoid this and to have "clear data" after every trade?

    Thank you
    Tony

    #2
    Tonynt,

    Thank you for your post.

    I recommend that you use TraceOrders = true in your Initialize() method.

    This will print when the orders are submitted and if they get ignored or not to the output window.
    Tools -> Output Window
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by tonynt View Post
      Hello,

      my script strategies do correct entries, trade management and exits. But after exits it occurs that new entries are not done - even when conditions are true.

      I have no idea why this occurs. Is there anything to reset maybe somewhere in the script to avoid this and to have "clear data" after every trade?

      Thank you
      Tony
      What are the errors in your log?

      Comment


        #4
        Hello,

        thank you for your replies. There appears in the log and in outputwindow

        "**NT** Error on calling 'OnBarUpdate' method for strategy 'a1S5Fn/f1beee184f63491cb68dbe6c9391aae2': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

        I do not understand this, there are many bars and there is an entry. Only when exits are done then there is no new entry.

        Thank you!
        Tony

        Comment


          #5
          TonyNT,

          This means that you are indexing a value further back than there are bars available.
          See the sample below for more information
          http://www.ninjatrader.com/support/f...ead.php?t=3170
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            Hello,

            thank you for your reply. Yes, this I understand (I assume).

            But its unlogical with the behavior: the strategy works as soon as enabled (there are less bars than later). Then after the exits there is no new entry. I have to set in the strategy settings window enable to false then apply and then again enable to true and then it works and there are entries. Isn´t this unlogical with the message in outputwindow?

            Thank you
            Tony


            Originally posted by NinjaTrader_Cal View Post
            TonyNT,

            This means that you are indexing a value further back than there are bars available.
            See the sample below for more information
            http://www.ninjatrader.com/support/f...ead.php?t=3170

            Comment


              #7
              Do you have a CurrentBar check in your OnBarUpdate()?

              something like -
              if(CurrentBar < 1) return;
              Cal H.NinjaTrader Customer Service

              Comment


                #8
                Hello,

                thank you so much for your support.

                No, I do not have. I will immediately add and then on Monday with data check out.

                But how can this be the issue if the entries are correct when I enable the strategy and the entry is done as soon conditions are true. But later - when there are more bars! - the entry is not done??

                For your information this happens with my "immediate entry setup"eg for short strategy with

                if (Closes[2][0] <= Opens[2][0]
                && Closes[2][0] < Highs[2][0]
                && Position.MarketPosition == MarketPosition.Flat
                )

                Thank you
                Tony

                Originally posted by NinjaTrader_Cal View Post
                Do you have a CurrentBar check in your OnBarUpdate()?

                something like -
                if(CurrentBar < 1) return;

                Comment


                  #9
                  TonyNT,

                  If you are using multiseries, then you need to ensure that all the data series have enough bars

                  if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired....)
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #10
                    Cal,


                    once again PLEASE. How can the entry be done when enabling the strategy and later - there are more bars - not done. There must be enough bars later when there have been enough bars before. Correct me if I´m wrong.

                    Thank you
                    Tony


                    Originally posted by NinjaTrader_Cal View Post
                    TonyNT,

                    If you are using multiseries, then you need to ensure that all the data series have enough bars

                    if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired....)

                    Comment


                      #11
                      TonyNT,

                      You'll need to share what is in your OnBarUpdate() to help further diagnose
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #12
                        Cal,

                        In my onbarupdate I have

                        if (Historical)
                        //(BarsInProgress!=0)
                        return;

                        and then

                        if (BarsInProgress==2
                        && Closes[2][0] <= Opens[2][0]
                        && Closes[2][0] < Highs[2][0]
                        && Position.MarketPosition == MarketPosition.Flat
                        )


                        Thank you for your support.
                        Tony

                        Originally posted by NinjaTrader_Cal View Post
                        TonyNT,

                        You'll need to share what is in your OnBarUpdate() to help further diagnose
                        Last edited by tonynt; 08-01-2014, 03:07 PM.

                        Comment


                          #13
                          Originally posted by tonynt View Post
                          Cal,

                          In my onbarupdate I have

                          if (Historical)
                          //(BarsInProgress!=0)
                          return;

                          and then

                          if (BarsInProgress==2
                          && Closes[2][0] <= Opens[2][0]
                          && Closes[2][0] < Highs[2][0]
                          && Position.MarketPosition == MarketPosition.Flat
                          )


                          Thank you for your support.
                          Tony
                          You have described your problem multiple times as "orders not being made/taken". The relevant information is, therefore, how your orders are being coded, not the conditions that trigger orders. Albeit, that may also be an issue in this particular case.

                          Comment


                            #14
                            Hello,

                            thank you for your reply. Sorry for misunderstanding on my end.

                            This is how I do the entries with the mentioned conditions (that work for the first trade and then after closing the trade I have to disable strategies and enable again to have a new entry)

                            {
                            entryOrderSr3a=EnterShort(1, "Sr3a");
                            entryOrderSr3b=EnterShort(1, "Sr3b");
                            }



                            Thank you!
                            Tony




                            Originally posted by koganam View Post
                            You have described your problem multiple times as "orders not being made/taken". The relevant information is, therefore, how your orders are being coded, not the conditions that trigger orders. Albeit, that may also be an issue in this particular case.

                            Comment


                              #15
                              Originally posted by tonynt View Post
                              Hello,

                              thank you for your reply. Sorry for misunderstanding on my end.

                              This is how I do the entries with the mentioned conditions (that work for the first trade and then after closing the trade I have to disable strategies and enable again to have a new entry)

                              {
                              entryOrderSr3a=EnterShort(1, "Sr3a");
                              entryOrderSr3b=EnterShort(1, "Sr3b");
                              }



                              Thank you!
                              Tony
                              Is there any other code that processes these same IOrders, such as code in another event handler, or code that sets them to null?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Yesterday, 05:17 AM
                              0 responses
                              63 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              139 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              75 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              45 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              50 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X