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 yertle, Today, 08:38 AM
            6 responses
            24 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            24 views
            0 likes
            Last Post algospoke  
            Started by ghoul, Today, 06:02 PM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            46 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            23 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X