NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 05-13-2009, 10:02 AM   #1
rsi77
Senior Member
 
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default Determining regular session close on 24hr chart

I'm building a strategy which needs calculate two sets of pivot points--one set on a futures contract using regular hours (8:30AM - 3:15PM) H, L, C, and another set which uses 24 hours H, L, C. The chart on which the strategy will be placed includes the Globex session. I am extracting the regular session H,L,C from a 2nd data set with a bar interval of 30m. I start counting Highs and lows as soon as the 30m bar time = 9000000, meaning the first bar of the regular session. I stop counting Highs and lows when the bar time = 153000, meaning the last bar of the regular session (which actually ends at 15:15, but there are no trades between 15:15 and 15:30). All of my calculations work fine except that sometimes the regular session close which I take from the 30m bar which ends at 15:30 is off by a tick. I'm not sure why. Sometimes its correct, but other tiems the close doesn't match the close on my comparison chart which is a 30m chart set to session start/stop = 8:30AM/3:15PM.
Do you know what the problem is?
OR...is there an easier way of doing what I'm trying to do here, (i.e. extract regular session H,L,C from a 24hour chart which is not necessarily set to minute intervals)?

Thanks,

rsi77
rsi77 is offline  
Reply With Quote
Old 05-13-2009, 10:15 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

rsi77,

If the data says there is a tick coming in at 15:30 that moves it for you then that is what you will get in your calculations. I suggest you use CalculateOnBarClose = false and just look in real-time to see when and what your data comes in as.
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-13-2009, 10:32 AM   #3
rsi77
Senior Member
 
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default

"If the data says there is a tick coming in at 15:30 that moves it for you then that is what you will get in your calculations. I suggest you use CalculateOnBarClose = false and just look in real-time to see when and what your data comes in as."

So if I want to know the beginning of the session I would use

if (ToTime(Time[0]) > 83000 and ToTime(Time[1]) < 83000)
{
start tracking H, L;
}

and

if (ToTime(Time[0]) > 151500 and ToTime(Time[1]) < 151500)
{
RegSesClose=Close[1];
}

Am I understanding this correctly???

Thanks
rsi77 is offline  
Reply With Quote
Old 05-13-2009, 10:37 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Not sure why you would check Time[0] and Time[1] also. The conditions you have outlined are mutually inclusive. If Time[0] > 8:30 for sure Time[1] < 8:30.
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-13-2009, 10:46 AM   #5
rsi77
Senior Member
 
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default

No, if time[0] = 9:50 and time[1]=9:48 they are both > 8:30....I wanted to isolate the case where I'm looking at the first bar after 8:30.
I'm not sure I understand what you're getting at.

In any case I solved my problem by adding another data stream with 15m interval. It calculates regular session close properly every time.

I still need the 30m bars because I'm using them to calculate MP numbers which are also part of my strategy.

rsi77
rsi77 is offline  
Reply With Quote
Old 05-13-2009, 10:53 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Not sure I am following you. If you want the bar after 8:30 just check for time to be equal to the next bar. On 30 minute series that would mean 9:00. On 15 minute that would mean 8:45.

In either case, since you have it resolved we will leave it at that.
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-13-2009, 11:36 AM   #7
rsi77
Senior Member
 
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default

OK, I had forgotten that I had "=" instead of ">".

So setting on bar update to false will make it work with 30m bars?

Will this mean that the strategy will be slower since it's checking more often?

Is there an advantage to keep using 15m bars with "on bar update = true" in terms of speed of the strategy?

Thanks.
rsi77 is offline  
Reply With Quote
Old 05-13-2009, 11:49 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

CalculateOnBarClose will not change your timestamps. On thirty minute bars Time[0] is always 9:30 for instance. You cannot check 9:15 timestamps on 30 min series because there will be no bars with that timestamp regardless of if you use true or false. You will still need 15min series.
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-13-2009, 11:55 AM   #9
rsi77
Senior Member
 
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
CalculateOnBarClose will not change your timestamps. On thirty minute bars Time[0] is always 9:30 for instance. You cannot check 9:15 timestamps on 30 min series because there will be no bars with that timestamp regardless of if you use true or false. You will still need 15min series.
But you said that the reason my 30m bars were getting inconsistent results could be due to CaluclateOnBarClose being set to true. How would changing it to false help? At this point I'm trying to learn something since I clearly don't understand this.

Thanks
rsi77 is offline  
Reply With Quote
Old 05-13-2009, 12:01 PM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Misunderstanding, I suggested you use as a means for you to see exactly what data you have as a check. It does not change anything for the bars. Furthermore it does not change timestamps.
NinjaTrader_Josh 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
Put Session Begin and Session End times in chart title Jim W. Suggestions And Feedback 1 03-12-2009 03:32 AM
Get last regular session date? suedeuno General Programming 1 01-12-2009 07:28 AM
early close session prior to holiday traderzbs Miscellaneous Support 1 12-26-2008 06:41 AM
Session times vs Open & Close Times Laserdan Charting 1 10-15-2008 05:46 PM
Determining "Last Bar On Chart" NinjaTrader_Ray General Programming 2 01-16-2007 03:17 PM


All times are GMT -6. The time now is 02:51 AM.