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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        30 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        17 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        9 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        16 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        19 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X