Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

creating zones

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

    creating zones

    Dear friends.
    I want to create at initialization of my strategy 10 zones with different colors.
    And then have possibility to then colors of this zones and opacity.
    I find to methods for creation of zones
    DrawRectangle("My rectangle" + CurrentBar, 10, 1, 0, 1.4, Color.Blue); - I test it on 6E
    but did not see any rectangle.
    Then I try DrawRegion("RegZ1", regStartBar, 0, Zone1High, Zone1Low, Color.Empty, Zone1Color, zone1Opacity);
    It works but I want to establish values of Zone1High at program code in a live mode on each bar and not only once before staring strategy.
    What you can recommend for me?

    #2
    Hi Daglas,

    Sorry, I did not follow this request. Can you please clarify what you're looking for with the statement below?

    It works but I want to establish values of Zone1High at program code in a live mode on each bar
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hi Daglas,

      Sorry, I did not follow this request. Can you please clarify what you're looking for with the statement below?
      I am sorry. I want to change properties of rectangle on each bar.

      Comment


        #4
        How do you want to change the properties?

        If it's based on internal calculations, then you can use a variable that is calculated with each OnBarUpdate(). That seems to be what you're doing with DrawRegion() in your first post.

        If it's based on a public input, then you can use the public input in any draw statement.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_RyanM View Post
          How do you want to change the properties?

          If it's based on internal calculations, then you can use a variable that is calculated with each OnBarUpdate(). That seems to be what you're doing with DrawRegion() in your first post.

          If it's based on a public input, then you can use the public input in any draw statement.
          I want to change properties based on internal calculations with each OnBarUpdate().
          I want to now how I can change this properties,just a few lines of code.
          Also I have a trouble with drawing. I can't see any objects witch I want to create in my strategy, I use examples from Help, and I use condition builder for example
          DrawText("tag1", "Text to draw", 10, 1000, Color.Black);
          DrawRectangle("tag1", false, 10, Low[10] - TickSize, 5, High[5] + Ticksize, Color.PaleGreen, Color.PaleGreen, 2);

          And I don't see them.

          Comment


            #6
            Are there any errors in your log tab?

            If you use the same tag id for both objects only the latest called one would be drawn, to see 2 objects or their history use unique tags as shown here -



            You could use the IRectangle available in NT7 to directly change properties -

            Comment


              #7
              Ok thx. I shall check all you say.

              Comment


                #8
                I have found some troubles via Output window. I can create rectangles, text captions and other graphical elements. But I have some limitations, which I read in Output window I can declare start bar and end bar for rectangle from 1 to 20 bars, and I want to create bars with more width. Also this rectangles are displayed only if time frame is not a range (4-8),
                this rectangles are displayed only on (1, 10, 30 *** minutes.)

                Comment


                  #9
                  Are you seeing any error messages in the log tab of the control center?
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_RyanM View Post
                    Are you seeing any error messages in the log tab of the control center?
                    Yes I see the same message in the log tab as in output window. You can watch screen-shots. When I trying to create rectangle into strategy I get a message that valid range from 0 to 20, when I use indicator I get message that valid range from 0 to 0
                    Attached Files

                    Comment


                      #11
                      You're running into this issue here:


                      A description of the issue and common solutions is provided in the link. You're attempting to access bars that don't exist, so need to prevent the code form attempting to access.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_RyanM View Post
                        You're running into this issue here:


                        A description of the issue and common solutions is provided in the link. You're attempting to access bars that don't exist, so need to prevent the code form attempting to access.
                        Ok. I have read it. But it's preventing solutions. And I not to solve 2 problems
                        1) put different graphical elements to chart, so I need to establish coordinates (can I do it in pixels, and not via bars?) .
                        2) I need to make calculations on history so I need to have access to old bars (100-200 bars ago)
                        How I can do this?
                        When I watch a chart I see a lot of bars much more then 20 or 100.

                        Comment


                          #13
                          Code:
                          2) I need to make calculations on history so I need to have access to old bars (100-200 bars ago)
                          How I can do this?
                          When I watch a chart I see a lot of bars much more then 20 or 100.
                          You have to be clearer in what you want to do.
                          1. Do you want there to be 100 bars before you start calculating, or
                          2. Do you want to start calculating with whatever you have, and then use 100 bars if there are more than 100 bars?

                          Comment


                            #14
                            There is no support for placing drawing objects with pixels, but you can override the plot method for this. We recommend only looking into this for advanced programmers.

                            Your issue is not related to the # of bars on the chart, but preventing NinjaTrader from accessing empty objects. If you draw an object 20 bars back starting at bars 0- 19, then you will run into the exception you got.

                            Please review the provided link once more, look for the lines of code highlighted in bold blue, and add them to your script. Change the value so that you are returning with the largest # of bars back that your script uses.

                            if (CurrentBar < 20)
                            return;
                            Last edited by NinjaTrader_RyanM1; 03-30-2011, 03:54 PM.
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_RyanM View Post

                              if (CurrentBar < 20)
                              return;
                              Ok. I understand it. Also I want to ask how can I place captions at the left up corner of chart window. I place them manually using drawing tools. I attached screen shot.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 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