Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

getting specific date and time HLOC data

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

    getting specific date and time HLOC data

    Hello,

    I have read a number of threads about this but I'm still having problems. I found some code that should do this for me. But, using this against the YM (mini dow) I am not getting the correct value back. Should the following code obtain the open value on February 22nd 2010? What is the time zone of the time input? I used 9:30 because of the example I found. 7:30 is the open time for me as I live in the MST timezone. My example code follows:


    Datetime datetoget;

    datetoget =
    new DateTime(2010, 2, 22, 9, 30, 0);

    int barsAgo = GetBar(datetoget);

    Print(datetoget+" " + PriorDayOHLC().PriorOpen[barsAgo]);


    NOTE: this output 2/22/2010 9:30:00 AM 10139

    #2
    Hello Tulanch,

    You're close, but need to change it to:
    Code:
     
    Print(datetoget + " " + Open[barsAgo]);
    If you use PriorDayOHLC you're getting the value of this indicator on 2-22-10 at 9:30. This is not the same as the open of the 9:30 bar. To see the distinction apply this indicator to your chart and look at the value for Prior Open at 9:30. It should match the output of your original code.

    The time zone used is whatever is on your charts. Most likely this will be according to your local PC clock.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      ok I changed the code as you indicated. I'm running my test indicator on a 5min chart of the YM. The open of the 5min bar on February 22nd at 9:30 on my chart is 10374 but the test indicator still returns the following "2/22/2010 9:30:00 AM 10139"

      here's the updated code I am using....

      datetoget =
      new DateTime(2010, 2, 22, 9, 30, 0);
      int barsAgo = GetBar(datetoget);

      Print(datetoget+" " + Open[barsAgo]);
      Last edited by tulanch; 02-24-2010, 05:19 PM.

      Comment


        #4
        Hello Tulanch,

        On my setup it's working using the code you supplied. Output value is 10374, same as the chart. Make sure to compile any changes(F5) and reapply the indicator.

        Try modifying your print statement to see which bar you're accessing:

        Code:
        Print(Time[barsAgo] + " " + Open[barsAgo]);
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I changed the print statement as follows....

          Print(datetoget+" " +Time[barsAgo] + " " + Open[barsAgo]);

          here is what I get

          2/22/2010 9:30:00 AM 2/4/2010 7:35:00 AM 10139

          2/4/2010 7:35:00 AM is the most left bar on my chart
          and it's open value is in fact 10139

          (using Vista home basic)

          does/would the session time settings on my machine have any affect on this? They are both set to 7:30AM
          , I found this to be the best setting to see the 7x24 data
          of YM putting a start session vertical line at 7:30am
          here is a cut paste the part of the code I "touched" within my test indicator....


          bool oktodraw;
          DateTime datetoget;


          protectedoverridevoid Initialize()
          {
          CalculateOnBarClose =
          true;
          Overlay =
          false;
          PriceTypeSupported =
          false;
          oktodraw =
          true;
          }

          protectedoverridevoid OnBarUpdate()
          {
          if( oktodraw )
          {
          oktodraw =
          false;
          datetoget =
          new DateTime(2010, 2, 22, 9, 30, 0);
          int barsAgo = GetBar(datetoget);

          Print(datetoget+" " +Time[barsAgo] + " " + Open[barsAgo]);
          }

          Comment


            #6
            Hello Tulanch,

            Your bool condition is having a strange effect on this. I got results similar to yours when I included it, and it worked fine when I removed it.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by wftrrdt, Today, 05:01 AM
            0 responses
            2 views
            0 likes
            Last Post wftrrdt
            by wftrrdt
             
            Started by wellbeingcbd, Today, 04:41 AM
            0 responses
            1 view
            0 likes
            Last Post wellbeingcbd  
            Started by piydasuknu, Today, 03:45 AM
            0 responses
            3 views
            0 likes
            Last Post piydasuknu  
            Started by ajdfkgjiojjhfihjg, Today, 03:20 AM
            0 responses
            3 views
            0 likes
            Last Post ajdfkgjiojjhfihjg  
            Started by keravitahere, Today, 01:56 AM
            0 responses
            2 views
            0 likes
            Last Post keravitahere  
            Working...
            X