![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Nov 2009
Posts: 205
Thanks: 0
Thanked 0 times in 0 posts
|
Trying to make it generic! instead of a hard time i.e 9,30,00
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
(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))
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |