Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

DataSeries Object Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    DataSeries Object Help

    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, 12:44 AM.

    #2
    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)

    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ScottWalsh, Today, 06:52 PM
    3 responses
    19 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    17 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    1 view
    0 likes
    Last Post cre8able  
    Started by Haiasi, Today, 06:53 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by ScottW, Today, 06:09 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X