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

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 Waxavi, Today, 02:10 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        4 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by elirion, Today, 01:36 AM
        0 responses
        4 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        4 views
        0 likes
        Last Post gentlebenthebear  
        Working...
        X