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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        68 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        151 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        100 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        288 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X