Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IsFirstTickOfBar on Range Chart - getting called before time?

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

    IsFirstTickOfBar on Range Chart - getting called before time?

    Hi,

    I added a 60 min data series to my indicator using the standard (I then add the indicator to a 5-Range Chart) :
    case State.Configure:
    AddDataSeries(BarsPeriodType.Minute, 60);

    And in OnBarUpdate, I put in the following:
    if(BarsInProgress == 1) //based on hour bar
    {
    if(IsFirstTickOfBar) //hour bar just closed
    {
    Print(String.Format("CurrentBar: {0} Time[0]: {1}", CurrentBar, Time[0].ToString("MM/dd/yyyy hh:mm:ss.fff tt")));
    Print(String.Format("Current time: {0}",DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt")));
    Print("---");
    ...
    However, it seems like IsFirstTickOfBar is getting called before it's time:
    CurrentBar: 62 Time[0]: 08/11/2021 11:00:00.000 AM
    Current time: 08/11/2021 01:02:08.587 PM
    ---
    CurrentBar: 63 Time[0]: 08/11/2021 12:00:00.000 PM
    Current time: 08/11/2021 01:02:08.625 PM
    ---
    CurrentBar: 64 Time[0]: 08/11/2021 01:00:00.000 PM
    Current time: 08/11/2021 01:02:08.659 PM
    ---
    CurrentBar: 65 Time[0]: 08/11/2021 02:00:00.000 PM
    Current time: 08/11/2021 01:02:08.661 PM

    Why would the first tick of bar be called for the 2:00 PM bar when it's only 01:02 PM? I guess I missed the lesson on dealing with Range chart - can I get some pointers on this?
    Thanks!

    #2
    Hello mav8rick,

    This would be expected. The first tick would be when the bar opens. For a 60 minute bar, this would be at the beginning of the hour. The first tick of a bar should not be near the close of the bar unless no data was received while that bar was open.

    If the bar closes at 2:00 PM, then the bar opened at 1:00 PM, so the first tick should be just after 1:00 PM..

    Also IsFirstTickOfBar requires using Calculate.OnEachTick (or Calculate.OnPriceChange). Further in historical this would require TickReplay.
    https://ninjatrader.com/support/foru...377#post773377
    Last edited by NinjaTrader_ChelseaB; 08-11-2021, 11:54 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea - realized that after checking the values...

      Comment

      Latest Posts

      Collapse

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