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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            94 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            140 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            125 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            74 views
            0 likes
            Last Post PaulMohn  
            Working...
            X