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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    164 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    317 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    245 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X