![]() |
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 Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Dec 2007
Location: Dallas, Texas
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
|
I have written an indicator that is working when I place it on a chart. I am now trying to use that indicator in a Strategy using BackTest and get the following error:
Error on calling 'OnBarUpdate method for strategy 'PTrent': Index was outside the bounds of the array. I put print statements in the indicator and find the logic has completed Initialize(). I would expect the next statement to be executed would be OnBarUpdate() but a print statement as the first line here is not executed. What is executed after Initialize() and before OnBarUpdate() that could cause this error. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
The Initialize method of other strategies found in the strategies folder will be called. Look for where "PTrent" is defined.
|
|
|
|
|
|
#3 |
|
Member
Join Date: Dec 2007
Location: Dallas, Texas
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks for the reply.
The only place PTrent exits is in the name of the running strategy. I am calling Indicator PT in the OnBarUpdate of PTrent Strategy with the following: Print( " "+ PT(Close,1,12).Filter[0]); A print statement just before this is printed. Then the Initialize routine in the Indicator PT is executed and prints show it finishes. At that point I get the error. Could the reference to .Filter[0] be causing the error at this point? There must be something executed in the Indicator that gives the error. It would be logical that the indicator must run before retuning a value unless it is the reference to .Filter[0]. |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Your assessment is correct so I recommend placing code throughout your indicator to find where the logic is fouling up.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Dec 2007
Location: Dallas, Texas
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
|
I have place Print statements throughout the Indicator and before and after the call to the Indicator in the Strategy. They indicate that the Strategy starts and the call to the indicator is made(see below). Once the call is made only the initialize method is executed (print statement at end of this procedure is printed). Then the error occurs.
The OnBarUpdate in the Indicator is never entered as there is a print statement as the first statement in that procedure. As far as I know there is no other routine I have access to that could fail between the time the Initialize method in the indicator is finished and the OnBarUpdate for the indicator is executed. So I have no way of telling where the error is coming from. The indicator does run fine when I apply it to a chart so there is something that is happening differently when it is call by the Strategy. |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Chiming in here late...
The error to me suggests that in your strategy PTrent, you are accessing an array with an index value outside of the current array bounds. doing something like this: Print(Close[1]); When CurrentBar == 0 would throw this error. If the problem was in the indicator itself, you would get an error referencing your indicator name. Here is some more helpful information. http://www.ninjatrader-support.com/v...ead.php?t=3170
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Dec 2007
Location: Dallas, Texas
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Ray. The problem was in the indicator. I was not filling the Filter DataSeries as I thought I was. Now the question is why did I get an error pointing to the Strategy before the indicator was even executed.
The strategy had the following code: if (CurrentBar> 50): { Print("ST St"); Print( " "+ PT(Close,1,12).Filter[0]); Print("ST End"); } The printout shows that I reach "ST St" and in the Indicator the Initialize was executed but not the "OnBarUpdate". So what was the strategy looking for before it executed the OnBarUpdate? |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Unfortunately I am not sure.
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling an ATM Strategy Within NinjaScript | Jim-Boulder | Strategy Development | 5 | 08-26-2010 02:54 AM |
| Indicator Error on Installing ver 6.1.0.6 | MichaelB | Installation and Licensing | 13 | 11-05-2007 09:25 AM |
| Indicator Error | buderim | Miscellaneous Support | 4 | 09-03-2007 01:46 AM |
| Using Strategy Wizard to develope Indicator on Indicator | mrlucky1x | Indicator Development | 3 | 08-25-2007 04:09 PM |
| Error with FirstTickOfBar in an indicator | SuzyG | Indicator Development | 2 | 02-11-2007 04:03 AM |