Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Array for Support & Resistance Zones

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

    Help with Array for Support & Resistance Zones

    Hi,

    Note: this is a general C# question but hope its ok to ask (I think a prior post said it was).

    I need to keep track of support and resistance zones, for example a support zone for stock ABC being $9-$10. To date I've not been able to master storing them in arrays, so as a work around I'm using declared variables like...
    SupportZone1Lower = $9
    SupportZone1Upper = $10
    SupportZone1ValidFromBarNumber = 199

    ...and every time a support zone changes, say it moves up, I'm rejigging them around, e.g.
    SupportZone2Lower = SupportZone1Lower;
    SupportZone2Upper = SupportZone1Upper;
    SupportZone2ValidFromBarNumber = SupportZone1ValidFromBarNumber;
    SupportZone1Lower = $11
    SupportZone1Upper = $12
    SupportZone1ValidFromBarNumber = 233

    This is becoming a NIGHTMARE to keep track of and I've got a MESS of declared variables in my strategy. I'm hoping to be able to store them like this (or similar)...
    [$9,$10,199],[$11,$12,233]

    ... and then be able to reference them - such as: finding the Support zone with the largest bar number. Hoping to ask a couple of newbie questions please:

    1. I've looked through the microsoft C# help guides and I think I need to approach this as an multi-dimensional array, does this sound like the right approach?

    2. Most of the guides seem to populate the array within the code when initializing (e.g. the guides hardcode numbers into the array from the beginning), whereas my strategy will add/remove/update as bars update. Is there any advice please for how to correctly initialize an empty array for say: double, double, int (supportzonelower, supportzoneupper, bar number)?

    Many thanks in advance

    ChainsawDR​

    #2
    Hello ChansawDR,

    Thanks for your post.

    We do not provide C# programming education services in our Support department as it is against our policies.

    That said, for finding information on creating multidimensional arrays in C#, you could do a quick Google search for something like 'Working with C# multidimensional arrays. When searching for this I was able to find a Microsoft Learn Programming Guide that discusses how to create and use arrays and multidimensional arrays.

    Ultimately, to learn more about this topic, you would need to further research information and examples about working with arrays in C#.

    This thread will also be open for other NinjaTrader Forum community members to share their insights on this topic

    Please let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks Brandon, I understand. I'll continue researching on the C# side (I suspect I need a dictionary as mixing variable types).

      Thanks again

      ChainsawDR

      Comment


        #4
        I've attached an indicator that I fixed for someone that uses lists to keep track of support and demand zones, thought you might get some ideas from this.

        SupDemZonesfixed.zip

        Comment


          #5
          This is fantastic Tasker-182, thank you very much indeed for sharing! I will study closely!

          Comment


            #6
            Hi,

            I do it like:

            private double[,] FiboGrXPr0 = new double[15,40000];

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X