Some Basic NinjaTrader Coding Questions -- IDataSeries
I am trying to convert the reverse-engineered JMA indicator found in the MAMulticolored zip under the download section to run on my Java-based platform. Most of the conversion is straight-forward, but I don't know how to handle the following buffers:
JMAValueBuffer = new DataSeries(this);
fC0Buffer = new DataSeries(this);
fA8Buffer = new DataSeries(this);
fC8Buffer = new DataSeries(this);
I either need to implement a DataSeries class which behaves the same as Ninja's DataSeries class, at least to the extent required by the indicator, or i need to remove the data series and use something else. The problem is that I can't find any API for DataSeries. Closest I found is here:
So maybe someone here can help me out with a few questions:
series = Input;
What is Input? Is that the most recent input in the buffer corresponding to the right-most datapoint on the chart or is that the left-most datapoint?
Series is a double. What is set in the buffer? Does the line above simply append the series value to the end of the data series array or does it push the value onto the front (pushing all previous elements in the array back by 1 index)?
If OnBarUpdate() is called on each bar update event (incoming tick), what does Input DataSeries contain? It seems that if Input contained all data received so far, the entire indicator would be recomputed for every input value on each update, which would be very inefficient.
DataSeries is a slight misnomer. A better name would have been DoubleSeries in keeping with the other XXSeries names such as BoolSeries, IntSeries, FloatSeries and StringSeries. I found this confusing at first.
These XXSeries classes are basically container classes that maintain an index synchronization that is aligned with the indexing scheme that is used to access data. Think of the "this" parameter that is passed into the DataSeries constructor as saying "Keep this double countainer's index syncronized with "this" indicators data index."
Ninatrader and Tradestation and I assume many other chart scripting languages use an indexing scheme where the rightmost bar (the last one created) is always index 0. And the second to the rightmost (one bar to the left) is index 1, etc. Close gives the closing price of the rightmost bar, Close is the closing price for the bar to it's left.
If you are familiar with "normal" container classes, when you add an item to say a List<>, the size of the list increases by one, and the last added item is accessed by "[Count-1]". Behind the scene I'm sure DataSeries is doing this, but to make it easier (a scripting language) some type of re-indexing or an offset calculation is probably being done in an override of the indexer ( [ ] ).
Since the DataSeries container is synchronized with this indexing scheme, DataSeries data is accessed exactly the same way - index 0 is the DataSeries value assiciated with the data at index 0. Since only one value can be stored at that index location, If you keep calling Set, it will just keep overwriting the data at that index.
Last edited by samWest; December 8th, 2010 at 05:39 PM.
The following 4 users say Thank You to samWest for this post: