• 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

Bars.GetSessionBar

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

    Bars.GetSessionBar

    With Chart Properties set to

    Session Begins: 6:00 PM
    Session Ends: 4:15 PM

    The following code returns questionable results

    int sessionBarsAgo = 3;
    if (Bars.GetSessionBar(sessionBarsAgo) != null)
    {
    Print("The prior session's time is:"+Bars.GetSessionBar(sessionBarsAgo).Time.ToStr ing());
    Print("The prior session's close is: " +Bars.GetSessionBar(sessionBarsAgo).Close.ToString ());
    }


    Here is the results:
    The prior session's time is: 5/27/2008 12:00:00 AM
    The prior session's close is: 1390.75

    The close value appears to be correct but I would have thought that thte time would have been either the 6:00 PM or 4:15 PM matching the Chart Properties Settings.

    What have I missed to get the time correct?

    Thanks

    #2
    Forgot to ask another question. How would I determine the bar number for

    Bars.GetSessionBar(sessionBarsAgo).Close


    I have not been able to get the correct coding combination for that.

    Thanks again

    Comment


      #3
      What you can do is mix and match to get what you want.
      Bars.GetSessionBar() can get you the date and use Bars.SessionBegin to get you the time.

      Then to get the bar number you want to use Bars.GetBar() to get the Bar Number.

      Check out the attached reference sample to show you how to get this all done.
      Attached Files
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Josh,

        Don't know how I overlooked the that example code before I posted the question but I did. This is excellent. Makes life so much easier.

        Many thanks.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by hiikila, Today, 02:40 AM
        0 responses
        1 view
        0 likes
        Last Post hiikila
        by hiikila
         
        Started by Beauregard, Yesterday, 11:50 PM
        0 responses
        12 views
        0 likes
        Last Post Beauregard  
        Started by renkodan, Yesterday, 11:56 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by J_o_s, 04-04-2020, 11:17 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by thetickfarmer, 04-04-2020, 04:44 PM
        2 responses
        20 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X