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

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.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,602 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X