![]() |
|
|||||||
| Tips Official NinjaScript tips and tricks |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
A common programming error is not checking to ensure there are enough bars contained in the data series you are accessing.
For example: Code:
protected override void OnBarUpdate()
{
if (Close[0] > Close[1])
// Do something
}
Following are two ways to ways to resolve this: Code:
protected override void OnBarUpdate()
{
if (CurrentBar < 1)
return;
if (Close[0] > Close[1])
// Do something
}
Code:
protected override void OnBarUpdate()
{
if (Close[0] > Close[Math.Min(CurrentBar, 1)])
// Do something
}
Ray
NinjaTrader Customer Service
Last edited by NinjaTrader_Josh; 08-01-2008 at 11:36 PM.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Format Data Series | tagomi | Charting | 5 | 09-21-2008 07:04 PM |
| Useing a Data Series | nigeleyre | General Programming | 5 | 08-22-2008 07:03 AM |
| Format Data Series Bars Back Problem | praveen_d | Miscellaneous Support | 3 | 08-08-2008 06:24 AM |
| data series | argito | Indicator Development | 3 | 05-30-2008 11:06 PM |
| Data Series question | NinjaTrader_Josh | Indicator Development | 4 | 05-25-2007 12:43 AM |