Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi TF BarsSinceEntry problem

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

    Multi TF BarsSinceEntry problem

    Hello,

    I have a problem with BarsSinceEntry returning values that are way too high (like 3700 instead of 2)

    I've tried to replicate the behaviour, and I do seem to see something odd. I ran the following strategy on 02 dec 2009 for future 6A 03-10, primary series 60 min.

    protected override void Initialize()
    {
    Add(PeriodType.Minute, 1);
    }

    protected override void OnBarUpdate()
    {
    EnterLong();
    Print("Bars0 = "+"("+BarsInProgress+") "+BarsSinceEntry(0,"",0));
    Print("Bars1 = "+"("+BarsInProgress+") "+BarsSinceEntry(1,"",0));

    if (Time[0].Hour == 17) {ExitLong();}
    }

    In the output, I see odd values, like

    Bars1 = (1) 14
    Bars0 = (1) 14
    Bars1 = (1) 14
    Bars0 = (0) 15
    Bars1 = (0) 15
    Bars0 = (1) 15
    Bars1 = (1) 15
    Bars0 = (1) 1036
    Bars1 = (1) 1036
    Bars0 = (1) 15
    Bars1 = (1) 15
    Bars0 = (1) 1038
    Bars1 = (1) 1038
    Bars0 = (1) 15
    Bars1 = (1) 15
    Bars0 = (1) 1040
    Bars1 = (1) 1040
    Bars0 = (1) 15
    Bars1 = (1) 15
    Bars0 = (1) 1042
    Bars1 = (1) 1042

    and

    Bars1 = (1) 3
    Bars0 = (1) 3
    Bars1 = (1) 3
    Bars0 = (1) 1316
    Bars1 = (1) 1316
    Bars0 = (1) 1317

    and

    Bars0 = (1) 2372
    Bars1 = (1) 2372
    Bars0 = (0) 2373
    Bars1 = (0) 2373
    Bars0 = (1) 21
    Bars1 = (1) 21
    Bars0 = (1) 2356


    Eventually all output is in the thousands, until the position is flattened.

    Please advise
    thanks
    Dave

    #2
    Dave,

    I suggest you first filter your code to be in BIP contexts. Submit your order only once in a single BIP and then also print CurrentBar values to see what those are so you can better understand what is happening.

    Please see if the attached works.
    Attached Files
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Yes, that works, but if I take off the bars in progress around the entry, and only enter when flat, I still get stuff like this

      1053 Entry
      1053 Bars0 = (1) 15 Flat
      1053 Bars1 = (1) 15 Flat
      1054 Bars0 = (1) 1036 Long
      1054 Bars1 = (1) 1036 Long

      So what's going on?

      here's the code

      if (Position.MarketPosition == MarketPosition.Flat) {
      EnterLong();
      Print(CurrentBar + " Entry");
      }


      Print(CurrentBar + " Bars0 = "+"("+BarsInProgress+") "+BarsSinceEntry(0,"",0)+" "+Position.MarketPosition);
      Print(CurrentBar + " Bars1 = "+"("+BarsInProgress+") "+BarsSinceEntry(1,"",0)+" "+Position.MarketPosition);

      if (Time[0].Hour == 17) {ExitLong();}

      Comment


        #4
        dave1992,

        In a multi-series strategy you have to filter it to a BIP. Whether that is via if(BarsInProgress) statement or with the signature of EnterLong(int barsInProgress, int quantity, string signalName).
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Are you saying that if you enter without specifying a BIP your strategy processing becomes unreliable?

          That doesn't make any sense. Even if you don't specify a BIP there is one and it's set. So the entry just goes against that.

          Comment


            #6
            dave1992,

            I am looking into it and will get back to you at a later point in time.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Please try again in the next version as we have made tweaks to the BarsSinceEntry/Exit() methods. Thanks for reporting this.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Josh View Post
                Please try again in the next version as we have made tweaks to the BarsSinceEntry/Exit() methods. Thanks for reporting this.

                I am testing the NT 6.5. 1000.14 now, and found a problem, too.

                If I use the BarsSinceEntry()>5 as a condition for any entry, my strategy returns no trade regardless of the bar number.
                Without it I have many trades.

                Any other version available without this problem?

                Comment


                  #9
                  Please use 7.0.0.9. It should have been resolved already.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    Please use 7.0.0.9. It should have been resolved already.
                    Thank you Josh.
                    Can you give me the link for the 7.0.0.9? I could not find it(I use a free platform and the version7 may not be available yet?)

                    I found the solution. Actually I needed the BarsSinceExit not the BarsSinceEntry. The ver6.5 did not work for the BarsSinceExit either.
                    And I wrote the code for the BarsSinceExit and it just worked fine:


                    Code:
                    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (Position.MarketPosition == MarketPosition.Flat) BSX.Set(BSX[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]] + [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) ; [/SIZE][/FONT][/SIZE][/FONT]
                    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]//BSX is the Bar Number since the Exit[/SIZE][/FONT]
                    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BSX.Set([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) ;[/SIZE][/FONT]
                    [/SIZE][/FONT]
                    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (BP[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]>[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] && BSX[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]>=bN) EnterLong() ; //bN is a bar Number[/SIZE][/FONT][/SIZE][/FONT]
                    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (SSP[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]>[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] && BSX[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]>=bN) EnterShort() ;[/SIZE][/FONT]
                    [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]
                    Last edited by dowhk; 02-11-2010, 09:57 PM.

                    Comment


                      #11
                      dowhk,

                      The link to download B9 is the same link you used to download whichever NT7 version you are currently on right now. There should be an email in your inbox regarding this release. Please check to ensure it is not in your spam folder.

                      If you cannot find it, please send an email to sales [at] ninjatrader [dot] com and let them know you are already part of the beta program and need the release email for B9 again.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      597 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      343 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      556 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      555 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X