![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
|
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
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Aug 2008
Posts: 102
Thanks: 3
Thanked 2 times in 1 post
|
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) |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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;
}
}
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Aug 2008
Posts: 102
Thanks: 3
Thanked 2 times in 1 post
|
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();
}
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();
}
}
Here the SMA will use data from 0859 0858 0857 .... So the result is clearly not the same ... |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Right. So which one do you want? Those are the two routes you can take. Programmatically setting session begin/end times is not supported.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |