Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRegion for Opening Range

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

    DrawRegion for Opening Range

    I'm trying to DrawRegion for Opening Range. I am using the following code:

    if (ToTime(Time[0]) >= ToTime(9, 45, 01) && ToTime(Time[0]) <= ToTime(16, 15, 00)){
    DrawRegion(
    "OpenRangeRegion" + Time[0].Date.ToString(), CurrentBar - rangeEndBar, 0, RangeHigh,
    RangeLow, Color.Transparent, Color.White,
    2);
    }

    The Region draws exactly as it should with one exception. When I scroll back on the chart to the previous day it has today's region not yesterday's. I know the "tag" property is the issue, but I don't know how to fix it. Is there a simple solution?
    Thanks

    #2
    Originally posted by kenb2004 View Post
    I'm trying to DrawRegion for Opening Range. I am using the following code:

    if (ToTime(Time[0]) >= ToTime(9, 45, 01) && ToTime(Time[0]) <= ToTime(16, 15, 00)){
    DrawRegion(
    "OpenRangeRegion" + Time[0].Date.ToString(), CurrentBar - rangeEndBar, 0, RangeHigh,
    RangeLow, Color.Transparent, Color.White,
    2);
    }

    The Region draws exactly as it should with one exception. When I scroll back on the chart to the previous day it has today's region not yesterday's. I know the "tag" property is the issue, but I don't know how to fix it. Is there a simple solution?
    Thanks
    Try using this as the tag: "OpenRangeRegion" + Time[0].Date.ToString("d")

    Comment


      #3
      koganam

      Thanks, I thought that was a great idea, but the result was the same. The current day is the only day that the region draws correctly. Any prior days have the same region as the current. What's interesting is that if I scroll back to a prior day on my chart and reload NinjaScript the region is redrawn correctly as the current day. And then each following day draws correctly as the "current day". But any prior days are incorrect.

      Thanks again

      Comment


        #4
        Originally posted by kenb2004 View Post
        koganam

        Thanks, I thought that was a great idea, but the result was the same. The current day is the only day that the region draws correctly. Any prior days have the same region as the current. What's interesting is that if I scroll back to a prior day on my chart and reload NinjaScript the region is redrawn correctly as the current day. And then each following day draws correctly as the "current day". But any prior days are incorrect.

        Thanks again
        Not sure that I understand Ken. Do you mean that there is always only one colored DrawRegion?

        Comment


          #5
          I'm using a DrawRegion to display an opening range. So if today's opening range on the ES was RH=1550 and RL=1545, then the today's DrawRegion would draw between 1550 and 1545. The problem is that if I scroll back on my chart to yesterday's opening range, it draws the same 1550 to 1545 DrawRegion , when yesterday's opening range was NOT 1550 to 1545.

          I have RangeHigh and RangeLow plots that work fine. I have DrawText that work fine and they all reflect the individual data of each day, with the exception of the one DrawRegion for the opening range. And they all use the tag code from post #1. I hope I'm being clear enough.
          Thanks
          Last edited by kenb2004; 07-15-2012, 04:15 PM.

          Comment


            #6
            Ken, if you would like to upload the indicator, I'd be happy to look at it for you and see why it's not drawing the regions correctly. You can PM it to me if you prefer.

            My first guess would be that RangeHigh and RangeLow might not be updating correctly. However, what sounds so peculiar is that when you scroll back, all regions on the chart and to the right of your scroll position are drawn correctly? I would love to figure out what is causing that...

            Comment


              #7
              Look in the Pivots indicator code to get around this.

              // This namespace holds all indicators and is required. Do not change it.
              namespace NinjaTrader.Indicator
              {
              /// <summary>
              /// Pivot Points.
              /// </summary>
              [Description("Pivot Points.")]
              public class Pivots : Indicator



              Originally posted by kenb2004 View Post
              I'm using a DrawRegion to display an opening range. So if today's opening range on the ES was RH=1550 and RL=1545, then the today's DrawRegion would draw between 1550 and 1545. The problem is that if I scroll back on my chart to yesterday's opening range, it draws the same 1550 to 1545 DrawRegion , when yesterday's opening range was NOT 1550 to 1545.

              I have RangeHigh and RangeLow plots that work fine. I have DrawText that work fine and they all reflect the individual data of each day, with the exception of the one DrawRegion for the opening range. And they all use the tag code from post #1. I hope I'm being clear enough.
              Thanks

              Comment


                #8
                Thank you for your input. The issue has been resolved by adding:
                = new DataSeries(this, MaximumBarsLookBack.Infinite);
                to each of the DataSeries. This is to overide Ninja's caching up to 256 bars.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Radano, 06-10-2021, 01:40 AM
                19 responses
                604 views
                0 likes
                Last Post Radano
                by Radano
                 
                Started by KenneGaray, Today, 03:48 AM
                0 responses
                3 views
                0 likes
                Last Post KenneGaray  
                Started by thanajo, 05-04-2021, 02:11 AM
                4 responses
                470 views
                0 likes
                Last Post tradingnasdaqprueba  
                Started by aa731, Today, 02:54 AM
                0 responses
                5 views
                0 likes
                Last Post aa731
                by aa731
                 
                Started by Christopher_R, Today, 12:29 AM
                0 responses
                10 views
                0 likes
                Last Post Christopher_R  
                Working...
                X