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 > Strategy Development

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

Reply
 
Thread Tools Display Modes
Old 12-10-2008, 04:38 PM   #1
ChiTrader2000
Senior Member
 
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
Default Is it possible to set "Session begins (local time)" from code?

Is it possible to set "Session begins (local time)" from code?

Whenever I close and reopen my Ninja Trader application then attempt to do a backtest on the e-mini S&P, the "Session begins (local time)" and "Session ends (local time)" values in the backtest properties DialogBox popup get set back to midnight.

I would like to do it in the code so that it won't keep getting reset whever I close and open Ninja Trader.

If this is not possible from code, can I set it somewhere in the Ninja Trader User Interface?
ChiTrader2000 is offline  
Reply With Quote
Old 12-11-2008, 04:59 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

Hi ChiTrader2000,

No, this cannot be set from your NinjaScript code.

But you can save your backtest results and then open then from the Strategy Analyzer when you work on them again, this will save the settings for the session.

Maybe more conveniently, you can add a time filter directly to your strategy and then let the code run on the normal 24 hrs session chart...please see this reference sample - http://www.ninjatrader-support2.com/...ead.php?t=3226
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 01-07-2009, 02:07 AM   #3
zark.be
Senior Member
 
Join Date: Aug 2008
Posts: 102
Thanks: 3
Thanked 2 times in 1 post
Default

sorry to re-vive an old thread.

but using Session Begin/End limits the data that you'll send to your indicators.

whereas just putting times and dates conditions in the onBarUpdate method will just limit orders.
The results will therefore be different.

anyother way of limiting Session Begin/End by code knowing that i only want that data in the indicators i call from my code ?
Should i create a DataSeries that i Set from within a time/date condition and call the indicators with that ? (And off course not synchronize the DS with the 'this' object or there'll be loads of NULL values in the DS and my indicator will go bonkers)
zark.be is offline  
Reply With Quote
Old 01-07-2009, 07:10 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

If you have an all encompassing time filter it will prevent any processing while outside of that time frame. This will have the same effect of changing session bars/end time of the chart. Not sure exactly what you are hoping for.

Code:
OnBarUpdate()
{
     if (time filter)
     {
          // indicator logic;
     }
}
All code outside of the filter will be processed on every single OnBarUpdate(). Any code inside the filter will only process when within the filter range.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-07-2009, 07:17 AM   #5
zark.be
Senior Member
 
Join Date: Aug 2008
Posts: 102
Thanks: 3
Thanked 2 times in 1 post
Default

I'm talking about the usage of an indicator in a strategy

Two cases :

1/ setting session begin = 0900 && session end = 1800
Code:
OnBarUpdate()
{
     
          if(SMA(Close,5)[0] > 900) EnterLong();


    
}
@9am
the SMA will use data from 1800 1759 1758 ...

2/ not putting a session begin end, and putting a "time filter"
Code:
OnBarUpdate()
{
     if (time filter)
     {
          if(SMA(Close,5)[0] > 900) EnterLong();


     }
}
@9am
Here the SMA will use data from 0859 0858 0857 ....


So the result is clearly not the same ...
zark.be is offline  
Reply With Quote
Old 01-07-2009, 07:27 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

Right. So which one do you want? Those are the two routes you can take. Programmatically setting session begin/end times is not supported.
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
Minute chart for "Day session" only? PKFFW Charting 2 06-17-2008 01:50 AM
Please add "Calmar" and "Sterling" ratios to Performance._Trades.TradesPerformance Elliott Wave Suggestions And Feedback 2 06-10-2008 09:57 PM
Failed to call method "Initialize" for indicator 'Test': Object reference not set to clearpicks Indicator Development 3 04-23-2008 12:53 PM
"'OrderRejected'. Strategy has sent cancel requests" & "There is no market data..." Elliott Wave Strategy Development 6 04-12-2008 12:03 AM
Changing Session Begins and Session Ends time forexample Charting 1 10-21-2007 01:16 AM


All times are GMT -6. The time now is 08:39 AM.