![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
|
I always have a tough time finding these.
This is the code that throws the error: Code:
while(CanNumber < CanCount)
{
TOI = Time[0];
barsAgo=GetBar(new DateTime(TOI.Year,01,01,00,00,00));
SubjBar = HighestBar(High,barsAgo);
Canhigh[CanNumber] = Math.Round(High[SubjBar],2);
SubjBar = LowestBar(Low,barsAgo);
Canlow[CanNumber] = Math.Round(Low[SubjBar],2);
Canopen[CanNumber] = Math.Round(Open[barsAgo],2);
Canclose[CanNumber] = Math.Round(Close[0],2);
CanNumber = CanNumber +1;
}
P.S. Code:
private int CanCount = 1;
private int CanNumber = 0;
Last edited by Sleeping Troll; 03-20-2010 at 05:09 PM.
Reason: Updated code to avoid use of reserved word(s)... Still no joy.
|
|
|
|
|
|
#2 |
|
Senior Member
|
I did stumble upon a nifty way to isolate these errors. Precede each section in question with:
if (CurrentBar < x)return; Use a unique x for each section and the error will tell you which section is throwing the error. if (CurrentBar < 1)return; while(CanNumber < CanCount) { if (CurrentBar < 2)return; TOI = Time[0]; if (CurrentBar < 3)return; barsAgo=GetBar(new DateTime(TOI.Year,01,01,00,00,00)); if (CurrentBar < 4)return; SubjBar = HighestBar(High,barsAgo); if (CurrentBar < 5)return; high[CanNumber] = High[SubjBar]; if (CurrentBar < 6)return; SubjBar = LowestBar(Low,barsAgo); if (CurrentBar < 7)return; low[CanNumber] = Low[SubjBar]; if (CurrentBar < 8)return; open[CanNumber] = Open[barsAgo]; if (CurrentBar < 9)return; close[CanNumber] = Close[0]; if (CurrentBar < 10)return; CanNumber++; } 5 is throwing error...
Last edited by Sleeping Troll; 03-20-2010 at 04:50 PM.
|
|
|
|
|
|
#3 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
Did you find the error? You also may want to try the try catch block: http://www.ninjatrader-support2.com/...ead.php?t=9825
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Senior Member
|
Yes, I did... Have not tried the file you provided yet, Will let you know when I do.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Object reference not set to an instance of an object | molecool | Version 7 Beta General Questions & Bug Reports | 14 | 12-02-2009 10:54 AM |
| Error calling 'OnExecution' - object reference not set to an instance of an object | kcsystemtrader | Strategy Development | 9 | 05-11-2009 03:11 PM |
| Error on running optimizer. Object reference not set to an instance of an object. | vasily20011 | Strategy Analyzer | 5 | 03-09-2009 08:09 AM |
| Object reference not set to an instance of an object | kcsystemtrader | Strategy Development | 6 | 02-09-2009 08:32 AM |
| Error: Object reference not set to an instance of an object. | Januson | Market Analyzer | 1 | 05-18-2007 12:12 AM |