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 set EOD to count firsts new session bars ?

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

    How to set EOD to count firsts new session bars ?

    I need to know in a reliable way when new session primary bars object begin to appear. For this, I've set the related "Trading hours template" with all of its EOD checkboxes ON, thinking that it should be good enough, but reading the guide I got confused about this method:
    "IsResetOnNewTradingDays[BarsInProgress]" that seems to be set like it states here:

    Property Value
    A bool[] when true, indicates the specified BarsArray is setup to run Break at EOD; otherwise false. Default value is false

    So it seems that besides trading hour EOD box checked, I need to set this "IsResetOnNewTradingDays[BarsInProgress]" as well for the primary bars object ?

    Thanks
    Last edited by pstrusi; 09-18-2017, 05:22 AM.

    #2
    Hello pstrusi,

    Thanks for opening the thread.

    IsResetOnNewTradingDays tells the NinjaScript if the specified BarsArray should use Break at EOD.

    If you want to detect when a new session occurs, I suggest to use a SessionIterator and check IsNewSession() or check IsFirstBarOfSession on the Bars object for a BarsInProgress == 0.

    IsNewSession() - https://ninjatrader.com/support/help...newsession.htm

    IsFirstBarOfSession - https://ninjatrader.com/support/help...rofsession.htm

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Hello pstrusi,

      Thanks for opening the thread.

      IsResetOnNewTradingDays tells the NinjaScript if the specified BarsArray should use Break at EOD.

      If you want to detect when a new session occurs, I suggest to use a SessionIterator and check IsNewSession() or check IsFirstBarOfSession on the Bars object for a BarsInProgress == 0.

      IsNewSession() - https://ninjatrader.com/support/help...newsession.htm

      IsFirstBarOfSession - https://ninjatrader.com/support/help...rofsession.htm

      Please let me know if I may be of further assistance.
      Hi Jim, I appreciate your suggestion and I will have it in mind, however, I still have the unanswered doubts:

      1. Is it not good enough to set "Trading hours" EOD checked boxes for primary bar to indicate when a new session begin?

      "Bars.BarsSinceNewTradingDay" works as it stated in the guide:

      Definition
      Returns the number of bars elapsed since the start of the trading day relative to the current bar processing.

      Property Value
      An int value representing the number of bars elapsed. This property cannot be set.

      2. Would I need "IsResetOnNewTradingDays" to set on true for the primary bar object, if I'm actually working with properties above?

      3. And now I wanna know: Why did you suggest such a different and more complex method if the subjected is addressed in point 1 and 2 in the NT8 guide ?
      Last edited by pstrusi; 09-18-2017, 11:34 AM.

      Comment


        #4
        Hello pstrusi,

        1. Is it not good enough to set "Trading hours" EOD checked boxes for primary bar to indicate that we need to know when a new session begin?
        The EOD check boxes will break a building bar at the session close and will create a new bar after the session close. If you want to mind this difference in the data series, it would be advised to check IsResetOnNewTradingDays. This, however, will not indicate when this new session occurs.

        2. Would I need "IsResetOnNewTradingDays" to set on true for the primary bar object, if I'm actually working with properties above?
        As this property can be set and overridden by the UI, I would suggest to check if this value is set to true rather than trying to set it in NinjaScript.

        You may test the following code on a Range chart with Break at EOD checked and unchecked:
        Code:
        if(Bars.BarsSinceNewTradingDay == 0 && IsResetOnNewTradingDays[0] == true)
        	Draw.Diamond(this, CurrentBar.ToString(), true, 0, Close[0], Brushes.Goldenrod);
        3. And now I wanna know: Why did you suggest such a different and more complex method if the subjected is addressed in point 1 and 2 in the NT8 guide ?
        As I understood your inquiry, you wanted to know when there is a new session on the primary bar. There can be several ways to do this, but we typically advise using a Session Iterator to interact with a Trading Hours template.

        If there is anything else I can do to assist further, please let me know.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello pstrusi,


          The EOD check boxes will break a building bar at the session close and will create a new bar after the session close. If you want to mind this difference in the data series, it would be advised to check IsResetOnNewTradingDays. This, however, will not indicate when this new session occurs.

          As this property can be set and overridden by the UI, I would suggest to check if this value is set to true rather than trying to set it in NinjaScript.

          You may test the following code on a Range chart with Break at EOD checked and unchecked:
          Code:
          if(Bars.BarsSinceNewTradingDay == 0 && IsResetOnNewTradingDays[0] == true)
          	Draw.Diamond(this, CurrentBar.ToString(), true, 0, Close[0], Brushes.Goldenrod);

          As I understood your inquiry, you wanted to know when there is a new session on the primary bar. There can be several ways to do this, but we typically advise using a Session Iterator to interact with a Trading Hours template.

          If there is anything else I can do to assist further, please let me know.
          Thanks for your more elaborated answer.

          I really thought that counting the first bars of a new session would really be got through a simple and direct way. The session iterator is more oriented to session times than counting bars of a new session.

          The other way, that originally I thought would be the simple way: The EOD check boxes, it seems more to let us know in a graphic way, but not to be used for an automated Strategy; and besides this, the confusing use of "BarsSinceNewTradingDay" that seems redundant considering the original EOD boxes.

          You should consider that it's a simple task that should be peformed in a simple and direct manner.

          Regards

          Comment


            #6
            Maybe I am missing the point her but have you thought of simply using
            if ( Bars.IsFirstBarOfSession ) ?

            Comment


              #7
              Originally posted by Zeos6 View Post
              Maybe I am missing the point her but have you thought of simply using
              if ( Bars.IsFirstBarOfSession ) ?
              It just returns true ONLY for the first bar of a new session. It could help to build another indirect way to count the bars of a new session.

              Comment


                #8
                Depending on what it is you are doing in the indicator, doing your own bar count might be a viable alternative with a very low performance impact.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by sidlercom80, 10-28-2023, 08:49 AM
                168 responses
                2,262 views
                0 likes
                Last Post sidlercom80  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by WeyldFalcon, 12-10-2020, 06:48 PM
                14 responses
                1,429 views
                0 likes
                Last Post Handclap0241  
                Started by DJ888, 04-16-2024, 06:09 PM
                2 responses
                9 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                41 views
                0 likes
                Last Post jeronymite  
                Working...
                X