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 cmoran13, 04-16-2026, 01:02 PM
        0 responses
        43 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        157 views
        2 likes
        Last Post CaptainJack  
        Working...
        X