NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 02-20-2012, 04:11 PM   #1
koganam
Senior Member
 
Join Date: Feb 2008
Location: http://omegasigmaindicators.com
Posts: 4,464
Thanks: 31
Thanked 1,859 times in 1,513 posts
Send a message via Skype™ to koganam
Question Did multi-timeframe processing get broken in NT7.0.1000.9?

One of my multi-timeframe scripts suddenly started throwing an error, and lost its plot, after I updated to NT 7.0.1000.9, on my development NT box. The log showed an index-access error, so I decided to investigate by setting up a new chart with the exact same timeframe parameters on my compilation NT 7.0.1000.8 box (which I had not yet updated). Much to my surprise, the problem does seem version specific.

To illustrate the problem, I have included an indicator file, which loads a secondary SPY BarSeries. (The name of the file is a question, not a statement ).

Here is the replication scenario.
  1. Chart: DIA, 5-minutes (or any intraday time-frame), 5 days of data (this is just what I used; it does not really matter how many days of data).
  2. Open the "Output Window"
  3. Load the indicator.
  4. Clear the "Output Window", so that we can be sure we have a clean slate
  5. Reload the chart (F5 reload).
  6. Scroll to the top and examine the output window..

On a NT7.0.1000.9 box, you will see numerous exceptions in the output window, followed by correct output. This is not just a demo problem. It did break a shipping indicator of mine, as the shipping indicator does not use Try/Catch blocks. The only reason we finally start to get valid output is because the exceptions are caught and thrown; hardly a recipe for good product.

NT 7.0.1000.8 produces absolutely clean output, with no exceptions. I can post the 2 outputs if you wish to see them.
Attached Files
File Type: cs BrokenMultiSeries.cs (6.9 KB, 18 views)
koganam is offline  
Reply With Quote
Old 02-20-2012, 04:50 PM   #2
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 5,719
Thanks: 189
Thanked 776 times in 743 posts
Default

Thanks for reporting Koganam,

I was not able to reproduce immediately. When testing on a R9 setup, I receive the following output:

Code:
CurrentBar: 0
BarsArray[0]: --  instrument='DIA' from='2012-02-15' to='2012-02-20' period=5 Min splitAdjusted=False dividendAdjusted=False bars=328
BarsArray[1]: --  instrument='SPY' from='2012-02-15' to='2012-02-20' period=5 Min splitAdjusted=False dividendAdjusted=False bars=541
Current Value of 1st BarsData: 128.57 at 2/15/2012 2:05:00 AM
Current Value of 2nd BarsData: 135.95 at 2/15/2012 2:05:00 AM
This is repeated on each currentbar with out any exceptions written to the output or the log file.

Can you please post the output from the two installations?
NinjaTrader_Matthew is offline  
Reply With Quote
Old 02-20-2012, 07:49 PM   #3
koganam
Senior Member
 
Join Date: Feb 2008
Location: http://omegasigmaindicators.com
Posts: 4,464
Thanks: 31
Thanked 1,859 times in 1,513 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by NinjaTrader_Matthew View Post
Thanks for reporting Koganam,

I was not able to reproduce immediately. When testing on a R9 setup, I receive the following output:

Code:
CurrentBar: 0
BarsArray[0]: --  instrument='DIA' from='2012-02-15' to='2012-02-20' period=5 Min splitAdjusted=False dividendAdjusted=False bars=328
BarsArray[1]: --  instrument='SPY' from='2012-02-15' to='2012-02-20' period=5 Min splitAdjusted=False dividendAdjusted=False bars=541
Current Value of 1st BarsData: 128.57 at 2/15/2012 2:05:00 AM
Current Value of 2nd BarsData: 135.95 at 2/15/2012 2:05:00 AM
This is repeated on each currentbar with out any exceptions written to the output or the log file.

Can you please post the output from the two installations?
Just to be sure, I rebooted the NT7-9 machine, my development machine, as I presume that most folks use a physical machine, so I thought that it would be best to be on physical hardware, just in case it makes a difference, no matter how small. The outputs are attached. The NT7-8 machine output is pretty much what you have, which is why I was taken aback when I got the errors on the NT7-9 machine.

I have no objection if you want to remote in to look at the machine. It is a bit heavy on applications installed, as it is a development machine, but I run this test with nothing else beyond the startup programs running.
Attached Files
File Type: txt NT7-9Output.txt (460.3 KB, 11 views)
File Type: txt NT7-8Output.txt (255.5 KB, 4 views)
koganam is offline  
Reply With Quote
Old 02-20-2012, 08:22 PM   #4
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,754
Thanks: 335
Thanked 470 times in 404 posts
Default

Quote:
Originally Posted by koganam View Post
Just to be sure, I rebooted the NT7-9 machine, my development machine, as I presume that most folks use a physical machine, so I thought that it would be best to be on physical hardware, just in case it makes a difference, no matter how small. The outputs are attached. The NT7-8 machine output is pretty much what you have, which is why I was taken aback when I got the errors on the NT7-9 machine.

I have no objection if you want to remote in to look at the machine. It is a bit heavy on applications installed, as it is a development machine, but I run this test with nothing else beyond the startup programs running.
NT8, vista, 32 bit, TDA connection with excessive BACKFILL issue problems.

I got it until 9:35 am?

I changed to 10 days and just about the same thing happened in NT 7-8 (the error started earlier, then it cleared up , and was fine by the 5 day data load issues).
Attached Files
File Type: txt NT7-8Output-tda.txt (353.0 KB, 9 views)
sledge is offline  
Reply With Quote
Old 02-21-2012, 08:44 AM   #5
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 5,719
Thanks: 189
Thanked 776 times in 743 posts
Default

Koganam,

I was able to reproduce this today on both R8 and R9. I was also able to resolve by adding a currentbars check:

Code:
 if(CurrentBars[0] < 1)
    return;
Please let me know if that does not resolve on your end.
NinjaTrader_Matthew is offline  
Reply With Quote
Old 02-21-2012, 10:04 AM   #6
koganam
Senior Member
 
Join Date: Feb 2008
Location: http://omegasigmaindicators.com
Posts: 4,464
Thanks: 31
Thanked 1,859 times in 1,513 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by NinjaTrader_Matthew View Post
Koganam,

I was able to reproduce this today on both R8 and R9. I was also able to resolve by adding a currentbars check:

Code:
 if(CurrentBars[0] < 1)
    return;
Please let me know if that does not resolve on your end.
While a bars escape does seem to clear up the situation, as the solution makes no logical sense, I am afraid that it is just masking what may be a deeper issue. As your initial test, (and sledge's test too) demonstrates, the issue does seem to show up in a somewhat inconsistent manner.

There was never an access to a past bar, so there should not ever have been an index error in the first place. The access was always to bar[0], so escaping the first bar seems to be rather a slapshot attempt to see what happens?
koganam is offline  
Reply With Quote
Old 02-21-2012, 10:50 AM   #7
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 5,719
Thanks: 189
Thanked 776 times in 743 posts
Default

Hello,

This can be generated if OnBarUpdate was attempted to run on an added series where there was no data to work from. Using a check of CurrentBars[0] < 0 would prevent this as well and is not necessarily related to accessing a past index value.
NinjaTrader_Matthew is offline  
Reply With Quote
Old 02-21-2012, 12:30 PM   #8
koganam
Senior Member
 
Join Date: Feb 2008
Location: http://omegasigmaindicators.com
Posts: 4,464
Thanks: 31
Thanked 1,859 times in 1,513 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by NinjaTrader_Matthew View Post
Hello,

This can be generated if OnBarUpdate was attempted to run on an added series where there was no data to work from. Using a check of CurrentBars[0] < 0 would prevent this as well and is not necessarily related to accessing a past index value.
Which I agree with, except that in this case the exception is being thrown on the primary bar series, BarsArray[0], not the added one.

Quote:
CurrentBar: 0
BarsArray[0]: -- instrument='DIA' from='2012-02-15' to='2012-02-20' period=5 Min splitAdjusted=True dividendAdjusted=True bars=429
BarsArray[1]: -- instrument='SPY' from='2012-02-15' to='2012-02-20' period=5 Min splitAdjusted=True dividendAdjusted=True bars=715
2/14/2012 04:25:00 barsArray access error! on BarsArray0 System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at NinjaTrader.Data.MemBars.GetClose(Int32 index)
at NinjaTrader.Data.Bars.GetClose(Int32 index)
at NinjaTrader.Indicator.DataSeriesHelper.get_Item(In t32 barsAgo)
at NinjaTrader.Indicator.BrokenMultiSeries.OnBarUpdat e()
koganam is offline  
Reply With Quote
Old 02-21-2012, 04:39 PM   #9
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 5,719
Thanks: 189
Thanked 776 times in 743 posts
Default

Right - it wouldn't matter which series was being called, the exception is just saying that that bar didn't exist when OnBarUpdate was running. When the first bar of BarsArray[0] was updating, there was no BarsArray[1]. Added a check for CurrentBars then returning will allow for the BarsArray to complete before the rest of the script is ran.
NinjaTrader_Matthew 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
NT7.1000.1 and NT7.1000.3 compiler difference pbcah Indicator Development 9 02-24-2011 04:33 PM
NT7 - Mulit-timeframe multi-instrument protective orders Shansen Strategy Development 2 10-30-2010 05:01 AM
Multi-timeframe strategy skips lower timeframe bars at one point adamus Version 7 Beta General Questions & Bug Reports 13 07-03-2010 01:36 AM
NT7 clarification - Multi timeframe strategy Shansen Version 7 Beta General Questions & Bug Reports 1 04-08-2010 07:32 AM
Multi-Time Frame Processing Question tazatek Strategy Development 5 04-06-2010 11:24 AM


All times are GMT -6. The time now is 08:09 PM.

FULL RISK DISCLOSURE: Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.