![]() |
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 |
|
Junior Member
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
|
I'm new to ninjascript and this is the second dumb question I'm going to ask. I'm very grateful to anyone who cares to answer: I am wondering if there is any way to recalculate a portion of the values within a dataseries object using the OnBarUpdate() method. Specifically, within the OnBarUpdate() method:
1) I first define two dataseries, say dataseries1 and dataseries2. Within the onbarupdate() method, dataseries1 is calculated. This dataseries needs not be changed. 2) I then define a parameter, in this case a double, whose value is an average of dataseries1 since the beginning of the trading day (it is actually a ratio of dataseries1 divided by barssincesession). 3) I then define a binary (int) whose value is 0 or 1 depending on whether dataseries1 is larger or smaller than the parameter. 4) Here is the key part. I let the value of dataseries2 to be the multiple of dataseries1 and the binary value: dataseries2[0]=dataseries2[1]+binary*dataseries1[0]. However,I'm pretty sure that the dataseries2 calculated this way will reflect all the parameter value which changes on each bar update. What I really want is to recalculate dataseries2 (the whole series, not just dataseries2[0]) using the latest parameter value (the whole plot for dataseries 2 from the beginning of the trading day on will therefore change upon a new bar, as opposed to just the latest value changing. With each new bar of the trading day, the value of dataseries2 since the beginning of the trading day is recalculated using the latest parameter value -> binary value, but the values in prior trading days are not recalculated). Is there a way to do that? I can supply my source code if further clarification is needed. Thanks!
Last edited by zenith1107; 05-21-2009 at 12:44 AM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
If you want to recalculate the WHOLE thing you need to loop through all of it and make changes to each one. Note that this will be very CPU intensive.
DataSeries.Set(int barsAgo, double value) http://www.ninjatrader-support.com/H...taSeriesObject
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 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 |
| Indicator: Using a DataSeries object to store calculations | NinjaTrader_Josh | Reference Samples | 0 | 04-30-2008 01:19 AM |
| Strategy: Synchronizing a DataSeries object to a secondary time frame | NinjaTrader_Josh | Reference Samples | 0 | 10-09-2007 01:56 AM |
| Error: Object reference not set to an instance of an object. | Januson | Market Analyzer | 1 | 05-18-2007 12:12 AM |