• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rectangle drawing with extended line on right and Price level

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

    Rectangle drawing with extended line on right and Price level

    Hi,

    I was looking how to draw rectangle with extended line (like Ray) to it's right showing price levels on the right margin. I could find sevel request from forum members over a long period of time since 2006. But I could not find any conclusion or any guideline on this anywhere in this forum. Can anyone guide me to the right direction on this please?

    I have attached a screenshot, though you can see the right end of the rentangle there and then the price, but the rectangle continues until price touches the rectangle and cross over it. I hope that clarifies.

    #2
    Hello asmmbillah, thanks for your note.

    You can use Draw.Rectangle and Draw.Ray to do this. Have you made an indicator that draws drawing tools before? A very simple one would be a dot above the bar whose close is greater than its open:

    OnBarUpdate()
    {
    if(Close[0] > Open[0])
    {
    Draw.Dot(this, "GreenBar"+CurrentBar, false, Time[0], High[0]+TickSize*5, Brushes.Red);
    }
    }

    Kind regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi ChrisL,

      Thanks for your note.

      Now it looks like this, Draw.Rectangle(this, "MyR2"+CurrentBar, false, Time[Strength+1], currentSwingHigh, Time[0].AddDays(7), Open[Strength+1], Brushes.Transparent, Brushes.Crimson, 20);

      I have added to plot 7 days ahead for that rectangle, but could not find a way to extend it indefinitely right side like Ray. Can you please guide? thanks in advance.

      Comment


        #4
        Hello asmmbillah, thanks for your reply.

        The most straight forward way of doing that would be to draw the Ray on top of the rectangle object. Otherwise, you would need to either make a custom drawing tool that does this, or do custom rendering in your indicator using the OnRender method.

        Kind regards.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          If I want to explore the custom drawing tool option, what should be the correct path to start. I haven’t coded custom drawing tool before. Where can I find the resources?

          Comment


            #6
            Hello asmmbillah, thanks for your reply.

            I found this thread that goes over custom drawing tools:
            https://ninjatrader.com/support/foru...-advice-please

            There is also this custom drawing tool from our colleague Jim:
            https://ninjatraderecosystem.com/use...-drawing-tool/

            The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

            Please let me know if you have any questions on this material.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi ChrisL,

              Thanks, those ref were very helpful.

              I have managed to draw the rectangle from the last swing high, but when price is going higher, I am trying to stop plotting the rectange, but it's not going anywhere. My code like below:

              if (high0 > currentSwingHigh)
              {
              Draw.Rectangle(this, "MyR3"+CurrentBars, false, Time[Swing(Strength).SwingHighBar(0, 1, 256)], currentSwingHigh, DateTime.Now, Open[Strength+1], Brushes.Crimson, null, 0); }

              Problem is, right side of the rectangle is keeping plotting even after the bar where price went above the last swing high. Can anyone suggest, how can I stop the rectangle on the blue circle bar in the screenshot, where High crossed the previous swing high price level?

              And I am trying to draw rectangle bottom line from previous bar's open of swing high which I have marked with a RED line and Red circle. Can anyone help?

              Comment


                #8
                Hello asmmbillah, thanks for your reply.

                It seems you would need to do some additional debugging in the script. I recommend using the Print statement to print out values to the Output window during run time. This way you can print out the actual values of SwingHighBar and check what they actually are. Once you spot the issue through the prints you can fix the code accordingly.

                Best regards.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hi, thanks for your notes. Following your suggestion few posts back, I am trying to solve the issue with custom rendering. Now rectangle is plotting. but I am trying it to stop plotting further when Price> highofRectangle; currently it is being removed, but I just want it to stop further and keep it like that. any guidance will be helpful.

                  Comment


                    #10
                    Hi asmmbillah, thanks for your reply.

                    If this is being done through a custom draw object, what are you doing differently from the other draw objects? If you are just ignoring OnRender when this condition becomes true, the tool would stop showing.

                    I look forward to hearing from you.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi ChrisL,

                      Thanks for your reply.
                      I am attaching the script for your ref. I am trying to draw a box at this point with simple mouse left click. And then stop rendering the box when price pass through the box from any side, but change the color only, if price does not pass through but goes inside and remain inside the box. I hope that clarifies. file attached in the below link. (it was previously with button click event, but I am trying to change it to mouse left click)

                      https://www.dropbox.com/s/29qkcx7phg...yTest.zip?dl=0

                      Last edited by asmmbillah; 09-05-2019, 07:38 PM.

                      Comment


                        #12
                        Hi asmmbillah, thanks for your reply.

                        There is too much code here for me to debug. I would recommend reducing this down to drawing a simple rectangle and remove all the extraneous data values like getting items from OnMarketData. Make that rectangle do what you want then add in the correct data values once it is working. This example from our colleague Chelsea demonstrates drawing with a left click from an indicator, this could prove useful.

                        https://ninjatrader.com/support/foru...-owner-problem

                        Best regards.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks for your reply. Due to the size, I am struggling to bring it down to your expected size. But as I am doing that, you mentioned about ignoring OnRender() in post #10, can you please explain further. an example will be very helpful. currently I am using a bool on marketdataevent.

                          Only thing I can think of is when the rectangle is removed, if last box from the list can be drawn or keep removing the latest box so that new box is not virtually not plotted.

                          please advise.
                          Last edited by asmmbillah; 09-06-2019, 03:28 PM.

                          Comment


                            #14
                            Hi asmmbillah, I will be back shortly with a stripped down example.

                            Thanks in advance for your patience.
                            Chris L.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi asmmbillah, thanks for your patience.

                              I put together a simple example and found that this will be all about keeping track of the bar values you want the rendering to occur on I set x to the latest bar and increase it every OnBarUpdate. See the attached example and this should get you pointed into the right direction for your indicator.

                              Best regards.
                              Attached Files
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RandanAL, Today, 09:05 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post RandanAL  
                              Started by cstern71, 09-02-2019, 10:30 AM
                              4 responses
                              58 views
                              0 likes
                              Last Post Lancer
                              by Lancer
                               
                              Started by Hanstanz, Today, 04:44 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post Hanstanz  
                              Started by juniortut, Today, 04:38 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post juniortut  
                              Started by rojiinko, Today, 03:58 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post rojiinko  
                              Working...
                              X