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.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      559 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      546 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X