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 > Application Technical Support > Strategy Analyzer

Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer.

Reply
 
Thread Tools Display Modes
Old 12-12-2007, 07:44 PM   #1
GuyFB
Member
 
Join Date: Dec 2007
Location: Dallas, Texas
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
Default Strategy calling Indicator Error

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.
GuyFB is offline  
Reply With Quote
Old 12-12-2007, 09:18 PM   #2
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
Default

The Initialize method of other strategies found in the strategies folder will be called. Look for where "PTrent" is defined.
KBJ is offline  
Reply With Quote
Old 12-12-2007, 10:23 PM   #3
GuyFB
Member
 
Join Date: Dec 2007
Location: Dallas, Texas
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
Default Strategy calling Indicator Error

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].
GuyFB is offline  
Reply With Quote
Old 12-13-2007, 12:08 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

Your assessment is correct so I recommend placing code throughout your indicator to find where the logic is fouling up.
NinjaTrader_Josh is offline  
Reply With Quote
Old 12-13-2007, 08:25 AM   #5
GuyFB
Member
 
Join Date: Dec 2007
Location: Dallas, Texas
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
Default

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.
GuyFB is offline  
Reply With Quote
Old 12-13-2007, 08:50 AM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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
NinjaTrader_Ray is offline  
Reply With Quote
Old 12-13-2007, 10:06 AM   #7
GuyFB
Member
 
Join Date: Dec 2007
Location: Dallas, Texas
Posts: 65
Thanks: 0
Thanked 0 times in 0 posts
Default

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?
GuyFB is offline  
Reply With Quote
Old 12-13-2007, 10:28 AM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Unfortunately I am not sure.
NinjaTrader_Ray 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
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


All times are GMT -6. The time now is 11:36 PM.