Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Maximum Bars Lookback
Collapse
X
-
NT 7 not as clean as NT 6.5
I have explored the problem and found an explanation. There was a bug in the indicator, which in some cases prevented that a value was written to the DateTimeSeries. In such a case NT7 behaves in a different way than NT 6.5. This can be shown with the following simple indicator, which prints the result to the output window:
#region Variables
private DateTimeSeries someDate;
#endregion
protected override void Initialize()
{
someDate = new DateTimeSeries(this);
}
protected override void OnBarUpdate()
{
if ( Time[0].DayOfWeek == DayOfWeek.Monday)
someDate.Set(Time[0]);
Print (CurrentBar + " " + Convert.ToString(someDate[0]));
}
With this indicator, values are written to the DateTimeSeries only on Monday. Nothing is written to the DateTimeSeries for the other days. So what happens?
NT 6.5. -> On Mondays the DateTimeSeries contains the affected values, on all other days the DateTimeSeries contains the default value "01.01.0001 00:00:00".
NT 7.0.0.13 set to "TwoHundredFiftySix" -> On Mondays the DateTimeSeries contains the affected values, on all other days the DateTimeSeries contains either "01.01.0001 00:00:00" or random values from prior fields of the DateTimeSeries.
NT 7.0.0.13 set set to "MaximumBarsLookBack.Infinite" via indicator dialogue -> "Error on calling 'OnBarUpdate' method for indicator 'Test' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."
Conclusion: If you do not affect a value to the DateTimeSeries,
- NT 6.5. writes the default value
- NT 7 (TwoHundredFiftySix) writes random values
- NT7 (Infinite) creates an out-of-range exception.
I don't think that the solution adopted for NT is really clean here.
Last edited by Harry; 04-03-2010, 12:35 PM.
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
72 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
42 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 12:02 AM
|
||
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
110 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
190 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
172 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|

Comment