• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Jschmelz, Today, 04:45 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by sisenberg, Today, 08:06 PM
      1 response
      7 views
      0 likes
      Last Post sisenberg  
      Started by priceisking, Today, 07:44 PM
      0 responses
      5 views
      0 likes
      Last Post priceisking  
      Started by saltminer, Today, 06:06 PM
      0 responses
      5 views
      0 likes
      Last Post saltminer  
      Started by KennyK, Today, 05:25 PM
      0 responses
      7 views
      0 likes
      Last Post KennyK
      by KennyK
       
      Working...
      X