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

Colored Support and Resistance Zones

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

    Colored Support and Resistance Zones

    I use the Constant Lines indicator to plot Support and Resistance lines. However a line is much too precise. An area of support (or resistance) may be from 0.5 to 2 points wide (in ES). Two contiguous line may not be easily visible in a busy chart. Thus, I wish to combine two immediate Constant Lines in a single S/R zone by giving them the same color and coloring (with transparency) the area in between the constant lines. There are examples of this in some indicators in the File Sharing Section (TRO Buy Zone, VWAP) but I am having problems in putting the indicator together. I am not a programmer and the painted and transparency/opacity section are in the properties section of the code and I do not know how too handle that. I can do minor modifications in the main code and I expect learn more in due time. Could someone provide guidance and help
    Thank you

    #2
    The coloring methods used in those indicators are more advanced techniques. Basically what you want to do is create two DataSeries. One for each of your lines. If you reference the indicators you mentioned already you will notice there is the following loop:
    Code:
    for (int seriesCount = 0; seriesCount < 2; seriesCount++)
    What you want to do is just change the loop parameters to reflect which DataSeries you want to be coloring. In this example the space between DataSeries 0 and DataSeries 1 will be colored.

    In essence, the color filling technique used follows the two lines and creates what is known as paths for each. It then fills in the space inbetween the two paths. The only modifying you need to do is to tell it which lines to create paths from.
    Last edited by NinjaTrader_JoshP; 08-23-2007, 05:28 PM.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      NT 6.5 will have a DrawRegion() method that will take care of this.
      RayNinjaTrader Customer Service

      Comment


        #4
        draw region requires so much memory that vista crashes

        hello,

        i have been using this method:


        to make a modification to the Dynamic Support and Resitance Indicator (see attachment) but when i load it on several charts and scroll back historical data my pc running vista locks the application and i am getting a low memory warning message.

        The pc has 4 GB ram, i am just using 4 instruments with 14 days historical data, i think this should not be an issue, please correct the attached indicator if possible, but i think ninjatrader has a bug that simply does not allow extensive drawing methods like the draw region ...

        regards
        peter
        Attached Files

        Comment


          #5
          We'll look into and will let you know.

          Comment


            #6
            There is a bug in your indicator code. Basically you are calling the indicator itself in your OnBarUpdate method of that indicator:

            DrawRegion("Bollinger Upper Region", CurrentBar, 0, SupportAndResistance(55).Resistance, SupportAndResistance(55).Support, Color.Black, Color.Blue, 1);

            -> infinite recursion

            Comment


              #7
              Originally posted by NinjaTrader_Dierk View Post
              There is a bug in your indicator code. Basically you are calling the indicator itself in your OnBarUpdate method of that indicator:

              DrawRegion("Bollinger Upper Region", CurrentBar, 0, SupportAndResistance(55).Resistance, SupportAndResistance(55).Support, Color.Black, Color.Blue, 1);

              -> infinite recursion
              According to the sample the drawregion should contain the top of the region (SupportAndResistance(55).Resistance) and after that the bottom of the region (SupportAndResistance(55).Support)

              Can you send me the code snippet what i should be using instead to get a region drawn inbetween the DynamicSR indicators Resistance and Support line?

              Thank you very much

              Comment


                #8
                Not sure I follow. Where in the sample code of SampleDrawRegion would see a recursive call of SampleDrawRegion (which is what you did on your code)?

                Unfortunately we don't have any other sample at hard at this time. As last resort you could contact a certified NinjaScript consultant: http://www.ninjatrader.com/webnew/pa...injaScript.htm

                Comment


                  #9
                  Originally posted by NinjaTrader_Dierk View Post
                  There is a bug in your indicator code. Basically you are calling the indicator itself in your OnBarUpdate method of that indicator:

                  DrawRegion("Bollinger Upper Region", CurrentBar, 0, SupportAndResistance(55).Resistance, SupportAndResistance(55).Support, Color.Black, Color.Blue, 1);

                  -> infinite recursion
                  In the example is this line of code:
                  DrawRegion("tag1", CurrentBar, 0, Bollinger(2, 14).Upper, Bollinger(2, 14).Lower, Color.Empty, Color.Lime, 2);

                  So i simply exchanged Bollinger.Upper with my indicator and its resistance
                  data series... (using attached indicator as a base from where to start my own indicator)

                  Maybe i misunderstand something, so maybe i should reference to the original DynamicSR indicator rather than putting every logic and draw function into a new indicator?
                  Attached Files

                  Comment


                    #10
                    Try
                    DrawRegion("tag1", CurrentBar, 0, Resistance, Support, Color.Empty, Color.Lime, 2);

                    Comment


                      #11
                      Originally posted by NinjaTrader_Dierk View Post
                      Try
                      DrawRegion("tag1", CurrentBar, 0, Resistance, Support, Color.Empty, Color.Lime, 2);
                      This works, great, thank you very much

                      Comment


                        #12
                        hi

                        I am trying to use the DrawRegion like this:
                        DrawRegion("fill", CurrentBar, 0, 1253, 1253, Color.Empty, Color.Lime, 2);
                        I just want to fill between two price values across the chart but I keep getting compile errors.

                        What section of the code do I put the DrawRegion?

                        Can I use just numbers?

                        Comment


                          #13
                          No you can't. One argument has to be a series.

                          Comment


                            #14
                            Hi Dierk,

                            so I am using the constant line indicator and I want to color between two lines so I use this line in the section

                            protected
                            overridevoid OnBarUpdate()

                            DrawRegion("fill", 0, CurrentBar, Line1Value, Line2Value, Color.Black, Color.Khaki, 2);

                            Line1Value and Line2Value are both DataSeries right, created by the Add?

                            But it still won't compile.

                            Comment


                              #15
                              I can't tell by your code snippet if LineValue1/2 are of type IDataSeries.

                              Please
                              a) consult the doc link I posted
                              b) check your code on the type of LineValue1/2
                              c) and take a close look at the compile error message.

                              This should provide you an idea what's going wrong.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by junkone, Today, 11:37 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post junkone
                              by junkone
                               
                              Started by frankthearm, Yesterday, 09:08 AM
                              12 responses
                              44 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by quantismo, 04-17-2024, 05:13 PM
                              5 responses
                              35 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by proptrade13, Today, 11:06 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by love2code2trade, 04-17-2024, 01:45 PM
                              4 responses
                              35 views
                              0 likes
                              Last Post love2code2trade  
                              Working...
                              X