Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LineBreakBarsType problem

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

    LineBreakBarsType problem

    Hi There

    I am using a strategy based on LineBreakBarsType

    I face a number of problem due, apparently, to a different behavior applied to this kind of bars.

    First thing is I want to test the first tick of a bar.
    It will always return true even if the bar is here for minutes and has moved several points on the price scale.

    Also, when testing bar number, it seems that the bar changes to the current bar, then to the previous, then to the current bar, then to the previous (thus making IsFirstTickofBar always true)

    I can't see how to approach this problem:

    Code:
            protected override void OnBarUpdate()
            {
    ​            if (CurrentBar < BarsRequiredToTrade)
                    return;
    
                Print("CurrentBar = " + CurrentBar);
                Print("IsFirstTickOfBar = " + IsFirstTickOfBar);
                if (IsFirstTickOfBar == true)
                {
                    // This is always true
    ...
    ​
    The output render as:

    CurrentBar = 1716
    IsFirstTickOfBar = True

    CurrentBar = 1717
    IsFirstTickOfBar = True

    CurrentBar = 1716
    IsFirstTickOfBar = True

    CurrentBar = 1717
    IsFirstTickOfBar = True

    CurrentBar = 1716
    IsFirstTickOfBar = True

    CurrentBar = 1717
    IsFirstTickOfBar = True

    CurrentBar = 1716
    IsFirstTickOfBar = True​

    #2
    Hello, thanks for writing in. In the historical data, Tick Replay must be enabled for IsFirstTickOfBar to work, otherwise, the script will just run OnBarClose. See here for documentation:

    https://ninjatrader.com/support/help...ping_for__tick _replay.htm

    Kind regards,
    -ChrisL

    Comment


      #3
      Thanks ChrisL

      Unfortunately, Tick Replay is disabled for Line Break bars:

      Comment


        #4
        Hi Philippe, Sorry for the oversight. The LineBreak bars are a RemoveLastBarSupported = true bar type, so Tick Replay can not be used and IsFirstTickOfBar also can not be used as it will always be True. Unfortunately there is no work around for this.

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Tick Replay must be enabled for IsFirstTickOfBar to work, otherwise, the script will just run OnBarClose.

          Kind regards,
          -ChrisL
          Why isn't this information on the actual documentation page for ​IsFirstTickOfBar? That seems like an obvious place to read about it wouldn't it? I swear the NT documentation is so thin sometimes it's better to go to the forums to read about things.

          Click image for larger version

Name:	Screenshot 2022-12-23 075324.png
Views:	97
Size:	108.9 KB
ID:	1228735

          Comment


            #6
            Hi Borgen, thanks for posting. It does say it in the documentation, there is a note about Remove Last Bar bar types on the page.

            Comment


              #7
              Maybe there is a language barrier here but that is clearly not the same as "Tick Replay must be enabled for IsFirstTickOfBar to work"... This is just poorly written documentation.

              Comment


                #8
                Hi Borgen, I sent a suggestion to the help guide admins they add a note about the Tick Replay historical requirement.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                648 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                574 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X