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

First Bar of Session

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

    First Bar of Session

    In the Strategy Builder what is first bar of session? Is it a custom session or like market hours (RTH) or something else?
    Thanks.

    #2
    Hello Trader17,

    When Bars.IsFirstBarOfSession is true, this indicates that a new session has begun and this is the first bar of that session.


    The session is based on the Trading Hours template applied to the chart or selected in the Strategy parameters in the Strategy Analyzer / Strategies tab.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks. Also in the drop down for the session templates I did not see a custom session. Can that be done too? Like say I want to use a four hour day session only for my strategy.
      Thanks.

      Comment


        #4
        Hello Trader17,

        Yes, trading hours templates can be created in the Tools -> Trading Hours window.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you. Looks like this is what might come to use for me in a breakout strategy. Like the break of the first bar of session.
          Thanks.

          Comment


            #6
            Thank you. Is the an expression in Strategy Builder that will look for a cross above/below the hi/lo of the first bar of session?
            Thanks.

            Comment


              #7
              Hello Trader17,

              I'm not clear on the condition you want.

              When you mention "a cross above/below the hi/lo" what is exactly is crossing?
              Are you looking for the close of the previous session to be greater than the open of the last bar of the previous session and then less than the low of the first bar of the new session?
              This wouldn't work. The close will never be lower than the low. It can only be equal to the low.

              You would add two conditions to the condition set. One that the bar is the first bar of the session, second would be the cross condition of whatever two series you are wanting to see cross.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                I am looking for the bid/ask to cross the hi/lo of the first bar of the session. When I tried "Bid crosses first bar of session I got an error. Makes sense as I did not know how to specify the hi/lo of the first bar of the session. The cross can happen anytime during the current session.
                Thanks.

                Comment


                  #9
                  Hello Trader17,

                  The high of the bar is High[0]. The entire high series is High.


                  The low of the bar is Low[0]. The entire low series is Low.


                  GetCurrentAsk and GetCurrentBid are not series. These return a snapshot of the current ask or bid price.





                  The ask and bid are within the high and low (if there is an ask higher than the high, then the high becomes that new ask).
                  Likely, you will never detect a cross with this.

                  What code do you have that is causing an error?

                  The following should compile (though it will never be true):
                  if (CrossAbove(High, GetCurrentAsk(), 1))
                  {
                  // execute code
                  }
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    What I am waiting for is a cross over of the price above the first bar of the session or below the first bar of the session. So I am using on each tick instead of on close in the strategy. So at any point in time during the session if price crosses above/below the hi/lo of the first bar of the session only then we trade that. I only want to focus on the break of the very first bar of the session only. No other bars.
                    Thanks.

                    Comment


                      #11
                      Hello Trader17,

                      You are trying to save the high of the first bar of the session and then on later bars you are trying to see if the current price has crossed above the high of the first bar of the session?

                      This would work.

                      When you say "I am waiting for is a cross over of the price above the first bar of the session" I'm not getting which two objects are being compared.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_ChelseaB View Post
                        Hello Trader17,

                        You are trying to save the high of the first bar of the session and then on later bars you are trying to see if the current price has crossed above the high of the first bar of the session?

                        This would work.

                        When you say "I am waiting for is a cross over of the price above the first bar of the session" I'm not getting which two objects are being compared.
                        You are right. So I want to see current price cross either the hi or the lo of the first bar of the session. I could not figure this out in the Strategy Builder though.
                        Thanks.

                        Comment


                          #13
                          Hello Trader17,

                          You need a double variable to store the price of the first bar of the session.

                          Then you would compare the current Close[0] price to the price of that variable (which is set when Bars.IsFirstBarOfSession is true.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            So I create 2 variables, one for the hi and the other for the low of the first bar of session. Then when price breaks either it trades the break, correct? And the high and low of the first bar of session will always be [0]? And I can use a hi, lo or close of subsequent bars or every price tick to look for the break? I thought when we use on bar close the most recent bar is also [0].
                            Thanks.

                            Comment


                              #15
                              Hello Trader17,

                              Yes, you would want two variables if you are wanting to store two values (the high and the low).

                              The currently processing bar will be barsAgo 0. When Bars.IsFirstBarOfSession is true, barsAgo 0 will be the bar you want to save to a variable. On later bars, that bar will no longer be barsAgo 0, which is why you are using that saved variable.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by CortexZenUSA, Today, 12:53 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Started by CortexZenUSA, Today, 12:46 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Started by usazencortex, Today, 12:43 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post usazencortex  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              168 responses
                              2,266 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X