[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]Add(PeriodType.Day, [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]CalculateOnBarClose = [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] Called on each bar update event (incoming tick)[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (BarsInProgress == [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2]Print([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Here"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [/COLOR][/SIZE][/FONT]
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Basic multi-time frame question
Collapse
X
-
Basic multi-time frame question
I have the following code. I'm using one minute data. Unfortunately nothing is printed out. If I change to "Add(PeriodType.Minute, 30)" there is printing but not when "Add(PeriodType.Minute, 60)" is used. What am I missing?
Code:Last edited by jonesr227; 08-25-2007, 08:11 PM.Tags: None
-
I don't see anything wrong with your code. Hmm. Do you have enough historical data loaded for the 60min bars? Are there any errors in the log?
I have attached a multi-instrument reference sample that has code exactly like yours and it works fine on my comp. Please see if it works for you.Attached FilesJosh P.NinjaTrader Customer Service
-
Originally posted by Josh View PostI don't see anything wrong with your code. Hmm. Do you have enough historical data loaded for the 60min bars? Are there any errors in the log?
I have attached a multi-instrument reference sample that has code exactly like yours and it works fine on my comp. Please see if it works for you.
I'm using 1 min data from 1/1/07 to the present. No errors are appearing in the log.
I tried your code. I don't know how to import this code (is this possible?) so I just cut and pasted into my code. The code works OK. I tried 60 minute up to 240 minutes and it all works. But as soon as I change "Add(PeriodType.Minute, 240);" for example to "Add(PeriodType.Day, 1);" it no longer works; i.e. nothing is printed out and nothing appears in the error log.
This should work, shouldn't it?
Comment
-
To import the NinjaScript archive: http://www.ninjatrader-support.com/H...e.html?Import1
Yes, theoretically it should work but like you've noticed it isn't. I am experiencing the same behavior you are so I will look into it some more and report back with my findings.
Edit: It would appear that when your primary bars are intraday bars you cannot add non-intraday bar objects (e.g. daily, weekly, etc). As a workaround you could load your primary bars as daily bars and then call your minute/tick/vol bars as secondary. When your primary bars are non-intraday you will also not have problems adding more non-intraday bars. I will contact the NinjaTrader development team to see if they know whats causing this.Last edited by NinjaTrader_JoshP; 08-26-2007, 12:24 AM.Josh P.NinjaTrader Customer Service
Comment
-
After talking to Dierk we have resolved the issue. The reason the strategy wouldn't print anything when you go from primary intraday bars and add secondary non-intraday bars is because of the two conditions that need to be satisfied first.- OnBarUpdate() is called only when it can find a common timestamp between both series (e.g. you need enough data for both time intervals).
- Both time intervals need to have enough bars loaded to meet the "Min. bars required" parameter before Condition #1 can be met. When your primary bars are 1min bars the default lookback is only 7 days, but the default "Min. bars required" is 20. This means by default you would not be able to find a common timestamp to satisfy Condition #1 because the daily bars are 20 days in, but 1mins are only 7 days in.
Code:BarsRequired = 0; //(any value up to 8 seems to work)
Josh P.NinjaTrader Customer Service
Comment
-
Josh,
Thanks for your help, but I'm still having problems.
Below is the code I'm using. I've added the BarsRequired = 0; statement. Unfortunately I'm still not seeing any print out. I'm using 1 minute bars as the primary bars.
You suggest a second solution: "set the "Min. bars required" parameter to less than or equal to 8 when you load the strategy (it is under the "General" category on the right-hand side of the Strategies window)."
I tried this as well and still no luck. By the "Strategies window" I assume you mean the backtest properties dialog? Are there any other important settings I should have to make this work?
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2]Add(PeriodType.Day, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]BarsRequired = [/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [FONT=Courier New][SIZE=2]CalculateOnBarClose = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]<summary>[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000] Called on each bar update event (incoming tick)[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#808080]///[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#808080]</summary>[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (BarsInProgress == [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Primary Bars: "[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]+Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (BarsInProgress == [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Secondary Bars: "[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]+Time[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]);[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
Last edited by jonesr227; 08-26-2007, 02:33 AM.
Comment
-
Originally posted by NinjaTrader_Ray View PostAre you connected to a provider that support historical daily data? If not, that will be your problem.
Here is a matrix of connectivity providers and their varying levels of data support.
http://www.ninjatrader-support.com/H...ricalData.html
Comment
-
Your strategy calls for daily bars this NinjaTrader needs access to historical daily data. Right now, it only has access to minute data.
You can either connect to any of our supported vendors that can provide Daily data or you can import daily data using the format specified in the link below.
In the meantime, you can backtest on any interval that uses minute based time intervals.RayNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by andrewtrades, Today, 04:57 PM
|
1 response
5 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
3 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
436 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
7 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
5 responses
19 views
0 likes
|
Last Post Today, 03:33 PM |
Comment