Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to save first tick of the session or bar.

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

    How to save first tick of the session or bar.

    Hello.
    How to save to variable first price on the session or first price on the bar?

    #2
    Hello Czarek,

    You can use Bars.IsFirstBarOfSession to know if a bar is the first bar of a session.


    You can use IsFirstTickOfBar in real-time when using Calculate as .OnEachTick or .OnPriceChange to know if this is the first tick of the bar.


    The link below has examples of setting variables.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello.
      Thanks for you reply.
      I still do not know what represent first tick price of the bar?
      For example last price (closing price ) of former bar is Close[0]
      What what is the first price of the first bar or current bar?

      Comment


        #4
        Hello Czarek,

        If you are looking at a 10 minute chart, then the first bar of the session would be the first 10 minutes of the trading session. So the ES contracts first bar of session would be the bar with a close time of 5:10PM Chicago time and an open time of 5:00PM. This is Bars.IsFirstBarOfSession.

        The first tick of a bar is the first traded price of that bar, which would be the same as the Open of that bar. This is IsFirstTickOfBar.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          I would like to save first tick of the bar price to variable.
          if (IsFirstTickOfBar)
          { myvariable == ????}
          Other words, I would like to catch and save first price of the bar.

          Comment


            #6
            Hello Czarek,

            Thanks for your reply.

            To capture the price of the first tick of the first bar of the session, you will need to run your code with the calculate mode Calculate.OnEachTick. You can then capture using:

            if (Bars.IsFirstBarOfSession && IsFirstTickOfBar)
            {
            myvariable = Close[0]; // On a tick basis Close[0] is the price level of the tick
            }

            Please note that if you are looking at historical data, the above code will return the close value of the bar and not the first tick of the bar because historical data only consists of the OHLC of the finished bar and not of each tick that made up the bar. To see the correct historical tick values you would need to enable Tick Replay or add a 1 tick data series.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            56 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            132 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X