Announcement

Collapse
No announcement yet.

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    594 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    554 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X