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

Count last 30 values

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

    Count last 30 values

    I want to keep a count of the 30 last instances where the spread between the swing high and swing low is > 10.

    Counting isn't the problem but how would I count only the last 30 instances?

    if SwingHigh - SwingLow > 10
    count++ // how would I count only the last 30 instances

    Any ideas would be appreciated.

    #2
    Hello sdauteuil,

    Thanks for your post.

    Can you provide further information or context on what you are looking for here? It is not clear what you are doing with the 30 instances.

    Are you saving bar numbers of each high/low point?



    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Basically my end goal is to create a ratio

      example


      // let's say over the last 30 times there was a new Swing High and during this period there were 12 instances where the SwingHigh - SwingLow was > 10 (where the price distance between the last swing low and current swing high is greater that 10 points)

      ratio = 12 / 30

      Hope that makes sense



      Last edited by sdauteuil; 08-02-2021, 12:41 PM.

      Comment


        #4
        Hello sdauteuil,

        Thanks for your reply.

        I think that to accomplish your goal you would need a C# list that is 30 long and in that list, you store the 30 values of swing high to swing low, as they occur. As a new swing high is found then that last one is removed from the list, keeping you with the latest 30. As needed, or when you add a new swing high, you can determine the new ratio by looping through the list of numbers and counting those > 10.

        I do not have any examples of this but recommend that you search C# tutorials online for List processing. Here is one that may help: https://csharp.net-tutorials.com/collections/lists/

        We can leave this thread open for any other members that may be able to provide further advice/suggestions on this subject.

        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by yertle, Today, 08:38 AM
        6 responses
        24 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        24 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        46 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        23 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X