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

detect R session bars

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

    detect R session bars

    How can I detect R session bars vs E session bars for ES? . I have tried the following code from the help files on 15min bars - this is placed inside OnBarUpdate:

    if (Bars.FirstBarOfSession)
    {
    Bars.Session.GetNextBeginEnd(BarsArray[0], 0, out sessionBegin, out sessionEnd);
    Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd);
    }

    The default result from <Use instrument settings> template is :

    Session Start: 7/10/2014 6:00:00 PM Session End: 7/11/2014 5:15:00 PM
    Session Start: 7/13/2014 6:00:00 PM Session End: 7/14/2014 5:15:00 PM
    Session Start: 7/14/2014 6:00:00 PM Session End: 7/15/2014 5:15:00 PM
    Session Start: 7/15/2014 6:00:00 PM Session End: 7/16/2014 5:15:00 PM
    Session Start: 7/16/2014 6:00:00 PM Session End: 7/17/2014 5:15:00 PM
    Session Start: 7/17/2014 6:00:00 PM Session End: 7/18/2014 5:15:00 PM

    How can I tell if the bar belongs to R session or E session?

    #2
    Originally posted by afshinmoshrefi View Post
    How can I detect R session bars vs E session bars for ES? . I have tried the following code from the help files on 15min bars - this is placed inside OnBarUpdate:

    if (Bars.FirstBarOfSession)
    {
    Bars.Session.GetNextBeginEnd(BarsArray[0], 0, out sessionBegin, out sessionEnd);
    Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd);
    }

    The default result from <Use instrument settings> template is :

    Session Start: 7/10/2014 6:00:00 PM Session End: 7/11/2014 5:15:00 PM
    Session Start: 7/13/2014 6:00:00 PM Session End: 7/14/2014 5:15:00 PM
    Session Start: 7/14/2014 6:00:00 PM Session End: 7/15/2014 5:15:00 PM
    Session Start: 7/15/2014 6:00:00 PM Session End: 7/16/2014 5:15:00 PM
    Session Start: 7/16/2014 6:00:00 PM Session End: 7/17/2014 5:15:00 PM
    Session Start: 7/17/2014 6:00:00 PM Session End: 7/18/2014 5:15:00 PM

    How can I tell if the bar belongs to R session or E session?
    You can use only one Session Template on a chart. If you want to make any finer distinctions of what time a bar is made, you will have to create and use your own time filters, and maybe a boolean flag or two.

    Comment


      #3
      Hello afshinmoshrefi,

      Thank you for your post and thank you to Koganam for their response.

      You would need to use a Session Template that would encompass all hours, ETH and RTH. Then check if the Time[0] is greater than the ToTime() for the RTH Session End and less than ETH hours Session End. Less than the RTH Session End would mean it is RTH hours.

      However, each Session will have different start and end times, so both the Session End and Start will need to be checked against Time[0]. Please let me know if you have any questions.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      58 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      36 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      21 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      9 views
      0 likes
      Last Post cre8able  
      Working...
      X