Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to call the Last Session's Close

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

    How to call the Last Session's Close

    Hi Ninjas,

    Everytime I begin a code for a new session, I need to do a one time calculation:

    The difference between the Last Session's Close minus the very first Close[0] of the new session. Searching in the help guide, I've known this interesting method: Bars.GetDayBar(1).Close which, supposedly it will have that last session Close that I want to find. So I did a little snippet to be run under OnStartUp() method, this is as follows:

    Code:
    if ( (Close[0]-Bars.GetDayBar(1).Close) >= 0 )
    {
    	// Do something
    }
    else
    {
    	// Do otherwise
    }
    Here's my doubt:

    In Forex a new session begins at 17:15 hours, so the method Bars.GetDayBar(1).Close, would really give me the the very Last Close at 17:00 of the PAST last session?

    If not, please would you indicate how to address it correctly?

    Thanks

    #2
    Hello,

    Thank you for the question.

    Are you just trying to get the Prior sessions close? If so, you could use the PriorDayOHLC indicator to do this rather than re creating all new logic.



    The syntax to get the Close would be:

    double value = PriorDayOHLC().PriorClose[0];

    Also this would need to be called after OnStartUp as OnStartUp is happening prior to the bars being processed on the chart. This can go anywhere in OnBarUpdate or the other override methods that happen after OnStartUp.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for your response Jesse, it seems that your solution is what I was looking for. I'll try it.

      Thanks again and best regards

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ageeholdings, Today, 07:43 AM
      0 responses
      7 views
      0 likes
      Last Post ageeholdings  
      Started by pibrew, Today, 06:37 AM
      0 responses
      4 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      14 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      12 views
      0 likes
      Last Post burtoninlondon  
      Working...
      X