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

Using IDataSeries

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

    Using IDataSeries

    Hi,
    I have a couple of newbie questions:

    1. I want to calculate the standard deviation on the bar size (high - low for each bar) for a series of bars.
    Given that standard deviation calculation StdDev requires an iDataSeries as a parameter, how can I achieve this?

    Eg, for a calculation on the standard deviation for the previous 10 bars, for instance,
    double value = StdDev((High - Low), 10); will not compile since you can't subtract one data series from another.

    2. Similarly, I want to calculate the average bar length (high - low) for a series going back a specific number of bars, but I can't see an appropriate method for this.

    3. Given that I will be calculating the above 2 calculations on previous bars in a series I imagine that if i try to calculate, say, standard deviation on the first bar in the series for the previous 10 bars in the series I would raise an out of bounds exception, what is an easy way to check that I am not going on the first bar in the series?

    #2
    MrScrillz, for this case you would want to calcuate the difference first in a custom data series for example and then run the StdDev calcs on this series instead - http://www.ninjatrader.com/support/f...ead.php?t=7299

    In your case though you can also use the Range() indicator as input for the StdDev, it would return a data series already if not called with an index ( [x] at it's end to request a specific double value from a series ).

    For not running into accessing non available bars, you can return out of the OnBarUpdate() for this first x bars on a chart, see this tip for sample code - http://www.ninjatrader.com/support/f...ead.php?t=3170
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by benmarkal, Yesterday, 12:52 PM
    3 responses
    22 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    18 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    11 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    6 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Working...
    X