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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    152 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    87 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    131 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    127 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    106 views
    0 likes
    Last Post CarlTrading  
    Working...
    X