Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get price range from first half hour or so of the trading day

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

    How to get price range from first half hour or so of the trading day

    Hi all,

    I want to compare prices to the opening half hour or so of the day to find out action compared to an opening range.

    What would I check for that? If I were to define an indicator's time frame for every 15 minutes I could check the high and low for the first 2 slots if I knew how to retrieve them, but the 0th slot is 'most recent'.

    Any suggestions would be appreciated.

    John

    #2
    Hello,

    You can make Time Filters using the ToTime(Time[0]) function.

    Please take a look at our reference Sample on Using a time filter to limit trading hours to help you get started:

    http://www.ninjatrader.com/support/f...ead.php?t=3226

    While this does not illustrate exactly what you wish to do, it should help you give you an idea of how you would get data from a specific time period and how to work with the Time() methods

    I would also suggest taking a look at our reference sample on Referencing the correct bar:

    http://www.ninjatrader.com/support/f...ead.php?t=4769

    Please let me know if you need further assistance.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thank you, this looks very helpful.

      Comment


        #4
        There are OpeningRange indicators available here which can use the session information and adjust to the open of each instrument.

        http://www.bigmiketrading.com/downlo...load.html?view
        http://www.bigmiketrading.com/downlo...load.html?view

        The indicators are available for free download, but forum membership is required. You can also send me a private message with your email, and I will then send you the indicators, as I have written them.

        Originally posted by jkmott59 View Post
        Hi all,

        I want to compare prices to the opening half hour or so of the day to find out action compared to an opening range.

        What would I check for that? If I were to define an indicator's time frame for every 15 minutes I could check the high and low for the first 2 slots if I knew how to retrieve them, but the 0th slot is 'most recent'.

        Any suggestions would be appreciated.

        John
        Attached Files
        Last edited by Harry; 04-14-2012, 08:51 AM.

        Comment


          #5
          Thanks, I found out that class variables are maintained on a per-row basis, which meant that I could use them to store a high and low. Here is the code. The value returned is 1 if the price is above the opening range, -1 if its below the opening range or 0 if its inside the opening range.

          public double LowRange = 1000000;
          public double HighRange = 0;
          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          // If we are in the opening range accrue high and low
          if (InTimeRange()) {
          if (Close[0] < LowRange) LowRange = Close[0];
          if (Close[0] > HighRange) HighRange = Close[0];
          Plot0.Set(0); // by definition we are still inside the opening range
          return;
          }
          // We are out of the open
          if (Close[0] < LowRange) {
          Plot0.Set(-1);
          return;
          }
          if (Close[0] > HighRange) {
          Plot0.Set(1);
          return;
          }
          Plot0.Set(0);
          }
          // Collect times between 8:30 to 9 (Central Time)
          protected bool InTimeRange() {
          if (DateTime.Now.Hour < 8) return false;
          if (DateTime.Now.Hour > 9) return false;
          if (DateTime.Now.Hour == 8 && DateTime.Now.Minute < 30) return false;
          return true;

          }
          Last edited by jkmott59; 04-14-2012, 10:55 AM. Reason: grammer error

          Comment


            #6
            As long as you trade an exchange of your timezone that should work. If you trade an exchange outside your timezone (as I usually do) you will face the challenge that there are various daylight savings schedules, which shift the opening period back and forth during the year. In that case you need to collect the information of the correct timezone from the session template under instrument settings to allow for conversion of the exchange time into your local time, for compensating the shift introduced via the daylight savings time.

            Comment


              #7
              Thanks, that's good to remember.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NicholasJoannette, Today, 12:16 PM
              0 responses
              3 views
              0 likes
              Last Post NicholasJoannette  
              Started by WalterSkinner, Today, 11:39 AM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by ntdev, Today, 10:53 AM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by aelagha, Today, 10:38 AM
              2 responses
              10 views
              0 likes
              Last Post aelagha
              by aelagha
               
              Started by aaadetos, Today, 10:36 AM
              3 responses
              13 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Working...
              X