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 sjsj2732, Yesterday, 04:31 AM
      0 responses
      27 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      283 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      280 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      131 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      90 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X