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

Drawing a box or line around a specific number of bars.

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

    Drawing a box or line around a specific number of bars.

    Hello,

    I see in the help how to draw horizontal lines, but I would like to draw a box around a specific number of bars (to identify custom patterns) and have that drawing stay with those bars. After searching here I found plenty on drawing horizontal lines, but how would I draw the sides to close it into a box and have it stay on those bars? Maybe I am not searching the right terms. If you could point me to a post that would be great, thank you.

    #2
    Hello HaveGunsWillTravel,

    Thanks for your post.

    If you are wanting to draw a box or rectangle, you could consider using Draw.Rectangle() to draw a rectangle on the chart.

    See this help guide documentation for more information about Draw.Rectangle(): https://ninjatrader.com/support/help..._rectangle.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      [QUOTE=NinjaTrader_BrandonH;n1181140]Hello HaveGunsWillTravel,
      Ha! Go figure, I saw draw line and got saturated on that thinking I need to draw four... Thanks again.

      Comment


        #4
        am struggling...
        Originally posted by NinjaTrader_BrandonH View Post
        Hello HaveGunsWillTravel,

        Thanks for your post.

        If you are wanting to draw a box or rectangle, you could consider using Draw.Rectangle() to draw a rectangle on the chart.

        See this help guide documentation for more information about Draw.Rectangle(): https://ninjatrader.com/support/help..._rectangle.htm

        Let us know if we may assist further.
        Should this be working? i am having some trouble...

        protected override void OnBarUpdate()
        {
        //Want to draw rectangle around these bars if they occur
        if((Close[0] < Close[1]) && (Close[1] < Close[2]) && (Open[0] > Open[1]) && (Open[1] > Open[2]))
        Draw.Rectangle(this, "iii", 2, Low[2] - TickSize, 0, High[0] + TickSize, Brushes.White);
        }
        }

        Comment


          #5
          Hello HaveGunsWillTravel,

          Thanks for your note.

          When the condition to draw the rectangle becomes true, the rectangle will be drawn on the chart.

          I have tested your Draw.Rectangle() method without the condition and the rectangle is drawn on the chart without issue. See the attached example strategy.

          To understand why the script is behaving as it is, such as drawing objects or not drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

          In the script, add prints (outside of any conditions) that print the values of every variable used in every condition along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

          Below is a link to a forum post that demonstrates how to use prints to understand behavior.
          https://ninjatrader.com/support/foru...121#post791121

          Please let me know if I may further assist
          Attached Files
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            [QUOTE=NinjaTrader_BrandonH;n1181213]Hello HaveGunsWillTravel,

            Thank you! I think I got it working now...

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            17 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            5 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,786 views
            0 likes
            Last Post Leafcutter  
            Started by poplagelu, Today, 05:00 AM
            0 responses
            3 views
            0 likes
            Last Post poplagelu  
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,408 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Working...
            X