Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What's wrong with "IsFirstTickOfBar"?

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

    What's wrong with "IsFirstTickOfBar"?

    Current TF - 5 minute
    TickReplay - On

    Code:
    ...
    else if (State == State.Configure)
    {
       AddDataSeries(Data.BarsPeriodType.[B]Minute, 5[/B]);
    }
    ...
    
    protected override void OnMarketData(MarketDataEventArgs e)
            {
                if (IsFirstTickOfBar && BarsInProgress==0)
                    Print(e.Time+" - "+BarsInProgress);
            }
    IsFirstTickOfBar always is False if the loaded timeframe is equal to the current timeframe

    #2
    Hello jshapen,

    IsFirstTickOfBar is used in OnBarUpdate(). When the tick triggering OnBarUpdate() is the first tick of the bar, this property will be true, for every series added to the script.

    Below is a link to the help guide.


    When used outside of OnBarUpdate(), its possible you might miss the value being true as the value will be updating based on OnBarUpdate() not OnMarketUpdate().
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      If in our example, replace
      Code:
       
       AddDataSeries(Data.BarsPeriodType.Minute, [B]5[/B]);
      with
      Code:
       
       AddDataSeries(Data.BarsPeriodType.Minute,[B] 15[/B]);
      then everything will be fine. IsFirstTickOfBar works as expected.

      Comment


        #4
        Hello jshapen,

        Are you expecting the IsFirstTickOfBar to not be true on the first tick of a bar when using a 15 minute bar type when printing from OnBarUpdate()?

        Below is a video that demonstrates IsFirstTickOfBar works fine in OnBarUpdate() even if the added series bar type and interval matches the primary series.
        https://drive.google.com/file/d/1dmB...w?usp=drivesdk
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        67 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        96 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        53 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        108 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        63 views
        0 likes
        Last Post PaulMohn  
        Working...
        X