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 habeebft, Today, 07:27 AM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_ChristopherS  
      Started by AveryFlynn, Today, 04:57 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by Max238, Today, 01:28 AM
      4 responses
      37 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by r68cervera, Today, 05:29 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by geddyisodin, Today, 05:20 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X