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

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:


            There is also this custom drawing tool from our colleague Jim:
            This is an expansion of the the NinjaTrader Lines Drawing Tool(s) that adds text boxes to each line that will show prices associated with the endpoint or where the line crosses the price scale. Vertical lines will show time stamps. Your own messages can be added to each text box. New settings can be set […]


            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.



                        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 michi08, 10-05-2018, 09:31 AM
                              5 responses
                              741 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by The_Sec, Today, 02:29 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post The_Sec
                              by The_Sec
                               
                              Started by tsantospinto, 04-12-2024, 07:04 PM
                              4 responses
                              62 views
                              0 likes
                              Last Post aligator  
                              Started by sightcareclickhere, Today, 01:55 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post sightcareclickhere  
                              Started by Mindset, 05-06-2023, 09:03 PM
                              9 responses
                              261 views
                              0 likes
                              Last Post ender_wiggum  
                              Working...
                              X