NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 04-12-2010, 01:29 PM   #1
mefTrader
Senior Member
 
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
Default Bars.BarsSinceSession before Session Start time

If the Session Start time = 930
Session End Time = 1600

If the time is 900 and I run Bars.BarsSinceSession is the result =-1 or does it report back -29? or something else

Similary for after the Session end time what would I expect for Bars.BarsSinceSession? say it is 1615 what is the expectant result then?


Regards
mefTrader is offline  
Reply With Quote
Old 04-12-2010, 01:41 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello mefTrader,

Thank you for your post.

Bars.BarsSinceSession will be non-negative and start counting from zero starting at the first bar that opens after the session time.

In your example, you are refering to times that are outside of defined session start and end times. These times won't exist in the context you're working from. There will not be a 9:00 bar or a 16:15 bar. There will be no strategy processing or indicator logic until 9:30.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 04-12-2010, 01:52 PM   #3
mefTrader
Senior Member
 
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
Default

How do I check premarket?

I currently have

(ToTime(DateTime.Now) <= ToTime(9, 30, 00)

Is my Session start time is 930

how can I check if the current time is premarket i.e before 9,30,00 as in this case...

Some thing like the following is what I want to do

(ToTime(DateTime.Now) <= SessionStartTime

can I do something like that?
mefTrader is offline  
Reply With Quote
Old 04-12-2010, 02:06 PM   #4
mefTrader
Senior Member
 
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
Default

Trying to make it generic! instead of a hard time i.e 9,30,00
mefTrader is offline  
Reply With Quote
Old 04-12-2010, 02:34 PM   #5
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

(ToTime(DateTime.Now) <= ToTime(9, 30, 00)

That statement will check your current system clock if before 9:30. This will only work in a live environment. (not backtesting)

If you want it to check the system date/time against session start times, you can use the following:

Code:
 
if (ToTime(System.DateTime.Now) <= ToTime (Bars.SessionBegin))
NinjaTrader_RyanM 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
Session Start Time and Net Change BigMike Market Analyzer 4 01-27-2010 12:39 PM
Session Start Time SystemTrading General Programming 6 02-23-2009 11:59 AM
Can 15-Minute Bar Backtest bars start on 7:20AM Session Start instead of 7:15 AM? ChiTrader2000 Strategy Development 5 01-30-2009 10:29 AM
Problem with Session Start Time bridenour Automated Trading 12 01-14-2009 11:50 AM
Session Start/End Time MindSabre General Programming 1 04-29-2007 12:29 AM


All times are GMT -6. The time now is 05:14 PM.