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

How to use DataSeries.ContainsValue(int barsAgo) && Reset()

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

    How to use DataSeries.ContainsValue(int barsAgo) && Reset()

    Hello,
    I'm trying to understand DataSeries better. I see the definitions of DataSeries.ContainsValue(int barsAgo) and Reset() in the Help, but there isn't an example of how to use these methods. Could someone provide me an example of how this methods are used?
    Thanks.

    #2
    Hello,

    Thank you for the post.

    In this case, I dont believe we have any specific examples of these items as they are generally only needed for specific use cases. ContainsValue simply lets you know if valid data has been set for the supplied BarsAgo. For example, if you are processing bars and set a value on bars 0 - 4 and 6 - 10, but on bar 5 the value is Reset(), bar number 5 would be an invalid data point. If you later wanted to access bar 5 specifically, ContainsValue could be used to make sure the value is valid. This is mainly only useful if you use Reset().

    Reset is used to remove a value from the currently processing bar. For example, a condition has occurred and the dataseries should no longer contain the value which was set, Reset can be used to effectively remove the data point and not just set it to a 0 value. As for an example, you can see how Reset was used in the ZigZag indicator, this is not a simple example by any means but does show how Reset can be used logically.

    I dont see that we have any stock indicators that utilize ContainsValue, it looks like the ZigZag is probably the best candidate for that use but its logic apparently didn't need it so it was not used. If you wanted to see how this works, you could add a Plot to an indicator and then use Reset on some bars. Then on every bar after the reset has been met or passed, print ContainsValue(0) to see if it equates true or false. This would be true if reset had not been used, if it had been used it would return false. The plot would also demonstrate how Reset works by displaying gaps in the plot where Reset was used.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Perr0Grande, Today, 08:16 PM
    0 responses
    2 views
    0 likes
    Last Post Perr0Grande  
    Started by elderan, Today, 08:03 PM
    0 responses
    5 views
    0 likes
    Last Post elderan
    by elderan
     
    Started by algospoke, Today, 06:40 PM
    0 responses
    10 views
    0 likes
    Last Post algospoke  
    Started by maybeimnotrader, Today, 05:46 PM
    0 responses
    11 views
    0 likes
    Last Post maybeimnotrader  
    Started by quantismo, Today, 05:13 PM
    0 responses
    7 views
    0 likes
    Last Post quantismo  
    Working...
    X