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

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.
    Brandon H.NinjaTrader Customer Service

    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 set2win, 08-04-2021, 09:23 AM
            39 responses
            1,000 views
            0 likes
            Last Post WaleeTheRobot  
            Started by md4866, Today, 08:15 PM
            0 responses
            7 views
            0 likes
            Last Post md4866
            by md4866
             
            Started by mjbatts91, Yesterday, 04:48 PM
            2 responses
            23 views
            0 likes
            Last Post mjbatts91  
            Started by pibrew, Today, 06:10 PM
            1 response
            19 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by actualfacts.2021, 07-25-2021, 03:11 PM
            8 responses
            1,188 views
            0 likes
            Last Post linkcou
            by linkcou
             
            Working...
            X