![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Sep 2011
Posts: 79
Thanks: 40
Thanked 2 times in 2 posts
|
hi, I am using the GetDayBar method. When the study loads, as the bars are being calculated, I get an "On Bar Update Error". I am guessing it is because I am referencing the Close values where GetDayBar is not returning an object because there is no 1 data one day back.
this is my code: Code:
double previousDayClose = Bars.GetDayBar(1).Close; thanks, Onn |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,183
Thanks: 130
Thanked 180 times in 179 posts
|
Hello onnb1,
Correct, this error is because in OnBarUpdate() is trying to access the data series that does not have enough data to calculate. More information about making sure you have enough data can be found at the following link. http://www.ninjatrader.com/support/f...ead.php?t=3170 This can be fixed by adding in a check to make sure we have enough data for the calculations in "OnBarUpdate()". Example: Code:
protected override void OnBarUpdate()
{
//Checks to make sure that there is a value for GetDayBar(1) before calculating
if (Bars.GetDayBar(1) != null)
{
double previousDayClose = Bars.GetDayBar(1).Close;
}
}
http://www.ninjatrader.com/support/h...?getdaybar.htm Please let me know if I can be of further assistance.
JC
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_JC for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| GetDayBar - whats wrong | nt2010 | General Programming | 31 | 05-30-2012 04:33 PM |
| GETDAYBAR and MAX | Kentoes | General Programming | 9 | 05-05-2012 06:48 PM |
| Bars.GetDayBar on Multi Time Frame | AntiMatter | General Programming | 6 | 04-23-2012 07:38 AM |
| Bars.GetDayBar(1).Close for multi-instrument | adam081527 | General Programming | 5 | 02-24-2012 10:14 AM |
| Bars.GetDayBar(1).Time returning null | drolles | General Programming | 9 | 01-18-2011 02:42 AM |