Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how does FirsTickOfBar fire

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

    how does FirsTickOfBar fire

    when i start my strategy in 5 minute bars @ 9:23:23, i may be in middle of a bar. when does the FirsTickOfBar fire. would i get it @ 9:25:00 or @ 9:23:23

    #2
    9:25:00. The first tick is when the bar starts building, not when you start your strategy.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      how do i get to the first bar of the strategy so that i can perform the same stuff as the firstickofbar

      Comment


        #4
        junkone,

        if (CurrentBar == 0) for first bar of strategy. By default though the first bar that is actually processed is 20 so maybe use if (CurrentBar == 20).

        If you want it on each session, if (Bars.FirstBarOfSession).
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          how many times would Bars.FirstBarOfSession be fired. i have CalculateOnBarClose = false
          and do my processing on OnBarUpdate()

          Comment


            #6
            In a backtest, once per first bar of session. In realtime, on every single tick put into that bar.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              So how would you use FirstTickOfBar in conjuction with OnBarUpdate. For instance.

              I wish to evaluate:

              Initialize()
              {CalculateOnBarClose = false;} /// evaluate on every tick

              <------->
              OnBarUpdate()
              If (IndicatorX >= IndicatorY) /// evaluate on every tick

              FirstTickOfBar()
              { EnterTradePositionHere } /// Fire only once condition has been met and only once during that bar at the tick/ next tick after condition has been met.

              Is this correct? If not what would be the correct construct for this.

              Cheers

              Chris

              Comment


                #8
                protected override void OnBarUpdate()
                {
                if (Historical){
                Print("in historical");
                return;
                }
                if (FirstTickOfBar) {

                firstTickOfBarSteps();


                }
                }

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                558 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X