Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to read the previous day?

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

    How to read the previous day?

    Hi there :-) I have a question: I need to the value from the highest (and lowest) closed bar on a 10-Min-Timeframe of the previous day, as you can see in the picture (value at the red line). How can I do this? It should be independent of starting time on the current day, the best would be if it looks back by date. Thank you for help.
    Uwe
    Attached Files

    #2
    Hello Uwe1981,

    There is a great example on getting Prior day data included with Ninjatrader. If you go to Tools -> Edit Ninjascript -> Indicator
    Look for the PriorDayOHLC indicator.
    This has all the Time references and shows how they are used; I think it would be a great resource to take a look at

    You could then implement a MIN() and MAX() to determine the highest and lowest from the data series.

    You may also want to use the Bars.FirstBarOfSession to find if the bar is the first bar of a session. here is more information on that.


    Here is Reference to the MIN and MAX methods



    Here are a couple of links to the ToDay and ToTime methods,





    Please let me know if I may be of further assistance
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse and thank you. I think that the PriorDayOHLC indicator isn't usefull because he returns the "touched" high, not the closed high. Maybe MIN/MAX with a while-loop could be the answer.

      But there still is the problem with the date. I will try to describe it once again. Today we have 12.04.2014. If I'm starting up now my strategy, the programm should read out and compare every bar from the 10-min yesterday's chart. I would do this in a loop. But I need some parameters like bar-timestamps to discover where yesterday begins and where it ends. The read xx BarsAgo wouldn't work because it describes a range of quantity and in this case the programm must start and read at 0:01 to get the full and right range. If I would start up on 9:00 it would read from 9:00 yesterday to 9:00 today.

      I think the easiest way would be to read out the bar-timestamps, searching back for the "yesterday 0:00" in a while loop and from there read out the range in a second while-loop (if date = 20140411 && time < 23,5,0 ) for example. But how can I get informations of date and time of a bar to control the loops?

      Greetings
      Uwe

      Comment


        #4
        Hello Uwe1981,

        Thank you for clarifying your question. Here is what I have come up with for your example.

        I have used the ToDay and ToTime methods to:
        Check if the current bars date that is being processed is from yesterday using a time stamp.
        If the bar is from yesterday, check if it is between a range of hours

        When you use the ToDate() or ToTime() methods, it returns a INT value of the date E.X.: 04/14/2014 would be 20140414 as a INT.

        Code:
        int yesterday = ToDay(DateTime.Now.AddDays(-1)); 
        // Gets yesterdays date based on what day it is currently.
        
        if (ToDay(Time[0]) == yesterday) // checks if current bars date is equal to yesterdays date
        {
          if (ToTime(Time[0]) >= 90000 && ToTime(Time[0]) <= 230500) // checks if the current time is between a range
          {
            // Logic goes here
          }
        }
        You can do as you said in your example too
        Code:
        if (ToDay(Time[0]) == yesterday && ToTime(Time[0]) <= 230500)
        {
        //Logic here
        }
        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Lumbeezl, 01-11-2022, 06:50 PM
        31 responses
        817 views
        1 like
        Last Post NinjaTrader_Adrian  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by swestendorf, Today, 11:14 AM
        2 responses
        6 views
        0 likes
        Last Post NinjaTrader_Kimberly  
        Started by Mupulen, Today, 11:26 AM
        0 responses
        6 views
        0 likes
        Last Post Mupulen
        by Mupulen
         
        Started by Sparkyboy, Today, 10:57 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X