NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 07-14-2012, 02:41 PM   #1
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default 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
kenb2004 is offline  
Reply With Quote
Old 07-14-2012, 05:56 PM   #2
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,225 times in 996 posts
Send a message via Skype™ to koganam
Default

Quote:
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")
koganam is online now  
Reply With Quote
Old 07-14-2012, 06:52 PM   #3
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

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
kenb2004 is offline  
Reply With Quote
Old 07-15-2012, 03:35 PM   #4
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,225 times in 996 posts
Send a message via Skype™ to koganam
Default

Quote:
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?
koganam is online now  
Reply With Quote
Old 07-15-2012, 04:12 PM   #5
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

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 at 04:15 PM.
kenb2004 is offline  
Reply With Quote
Old 07-15-2012, 06:44 PM   #6
Coder_Kenny
Junior Member
 
Join Date: Jul 2012
Location: Houston, TX
Posts: 17
Thanks: 1
Thanked 15 times in 9 posts
Default

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...
Coder_Kenny is offline  
Reply With Quote
Old 07-15-2012, 06:49 PM   #7
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,183
Thanks: 178
Thanked 300 times in 258 posts
Default

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



Quote:
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
sledge is offline  
Reply With Quote
Old 07-16-2012, 09:17 AM   #8
kenb2004
Senior Member
 
Join Date: Jul 2010
Posts: 415
Thanks: 1
Thanked 4 times in 4 posts
Default

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.
kenb2004 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening Range indicator mod99 Indicator Development 15 09-03-2011 02:06 PM
Opening range breakout bradypreston General Programming 7 02-28-2010 05:13 AM
Programing an opening range MJUK05 General Programming 6 02-09-2010 02:58 PM
Opening Range Breakout maninjapan Strategy Development 32 10-20-2009 02:55 PM
Please help with Opening Range Breakout Strategy OrderFlow Strategy Development 2 08-03-2009 04:30 AM


All times are GMT -6. The time now is 07:49 PM.