![]() |
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
|
|||||||
| Version 7 Beta General Questions & Bug Reports Ask questions here and post bug reports. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
|
I've been getting a lot of fatal errors recently, and I plucked the following message out of the trace file:
"...OnUnhandledThreadException ************exception trapped ************ 'BarsArray' property can't be accessed from within 'Initialize' method. at NinjaTrader.Indicator.IndicatorBase.get_BarsArray( ) This exception was thrown when the following was executed: (DTN-IQ) Data.Bars.GetBarsNow: instrument = 'YM 12-12' from (all the stuff it normally asks for; it's on a different computer so I'm not going to type it all out). All this was done on an optimization run. Now, this is something I'm aware of - I do not, in fact, attempt to access the "BarsArray" property anywhere in my code on Initialize(). I do access the following, and have been doing so without error for weeks now: PeriodType BarsPeriod That's it. So, if somebody has an idea why I would get the "BarsArray" exception, please let me know - |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 973 times in 956 posts
|
cgeorgan, please do not access those properties in the Initialize(), as they would have not been defined in there, as there's no bars object yet.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Senior Member
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
|
Quote:
I know the base property of my strategy - it knows what the base property of its own bars is. I access that value so that I can pass it to multiple new series that each have multiples of the base series. This exception is rare - if it were a real problem I'd get hit with it literally dozens of times an hour. What's the story? |
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 973 times in 956 posts
|
Correct, it might or might have not worked - the bottom line is - it should not be accessed in the Initialize() as there may be times when there's no object yet and thus you run into issues as you've seen -
http://www.ninjatrader.com/support/h...barsperiod.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Senior Member
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
|
Quote:
When, exactly, is this information available for use to the programmer? |
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 973 times in 956 posts
|
You can either work in OnStartUp() or the first OnBarUpdate() bar (CurrentBar == 0).
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#8 | |
|
Senior Member
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
|
Quote:
I access the "PeriodType" and "BarsPeriod" values in the Initialize() method because I use that to create higher time frame series based on the original series fed to the strategy. These higher time frame series are then added with the add() method within the Initialize() method, because that's the only place a programmer can add data series. I honestly can't think of another way to programmatically add different time series based off the initial time series without doing it this way. If your programmers know another way that does not include hard-coding the base time frame type and period, I'm interested in hearing it. Thanks! |
|
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 973 times in 956 posts
|
cgeorgan, your findings are accurate - we would unfortunately not support the dynamic adding of series 'on the fly' - you could just add a range of series per se and then access the bars array needed dynamically from the strategy (for example base 1 min, then add 2-15 in 1 min steps, drive strategy by BIP context then).
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#10 | |
|
Senior Member
Join Date: Dec 2008
Location: Ann Arbor, MI
Posts: 323
Thanks: 4
Thanked 0 times in 0 posts
|
Quote:
|
|
|
|
|
|
|
#11 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 973 times in 956 posts
|
Correct, it might or might not work for you - officially the dynamic adding of series is unfortunately not supported by us.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#12 | |
|
Senior Member
Join Date: Nov 2008
Location: UK
Posts: 637
Thanks: 0
Thanked 1 time in 1 post
|
Quote:
http://www.ninjatrader.com/support/f...628#post178628 |
|
|
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| exception trapped trying to change audio alert NT7 | gg80108 | Miscellaneous Support | 20 | 01-07-2011 02:18 PM |
| Add() method in Initialize() | gregsallee | Version 7 Beta General Questions & Bug Reports | 3 | 02-24-2010 09:50 AM |
| Exception Trapped | kiwibird | Automated Trading | 7 | 01-12-2009 08:41 AM |
| Syntax of BarsArray with LowestBar() method | Sidhartha | General Programming | 7 | 04-13-2008 09:55 AM |
| Accessing BarsArray[0].Period.Value inside Initialize() | jbeninga | Strategy Development | 10 | 03-22-2007 01:49 AM |