Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Rapine Heihei, Today, 08:19 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        3 views
        0 likes
        Last Post Rapine Heihei  
        Started by f.saeidi, Today, 08:01 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 07:51 PM
        0 responses
        6 views
        0 likes
        Last Post Rapine Heihei  
        Started by frslvr, 04-11-2024, 07:26 AM
        5 responses
        96 views
        1 like
        Last Post caryc123  
        Working...
        X