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

How can I Draw Object (Vertical Line) x pixel before the bar

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

    How can I Draw Object (Vertical Line) x pixel before the bar

    Due to performance, I am using onUpdateBar to draw all my objects. I have an object (a vertical line) that I would like to draw before the start of the bar, so it will not hide the bar and the additional information I have on the bar (Market Profile). As far as I notice, this option is not available with Draw.Line(), which only get the startBarsAgo and endBarsAgo as parameters.
    1. Is there any other way to do it?
    2. If not, can you help me with a small example that combines Draw objects from onUpdateBar and onRender?
    My challenge is I am using tickReply, and with onRender is that I have to figure out which data has changed, and only update it. In onUpdateBar, I know it's the last bar that changes, and for history, I only draw it when realttme start (I then draw all history).

    #2
    Hello Shai Samuel,

    Thanks for your post.

    You can use the Draw.VerticalLine() method and select the method overload that allows you to specify the DateTime of where to draw the line.

    I've attached an example where I have drawn a vertical line between bars by subtracting 30 seconds from the bars time stamp. The specific code is shown on the example. This example uses minute based bars which makes this an easy example but you can certainly apply the same method to non-time based bars by subtracting the current bar time from the previous bar time and then subtracting that difference (divided by 2) to place the vertical line between two non-time based bars.

    Click image for larger version

Name:	ShaiS-1.PNG
Views:	103
Size:	24.8 KB
ID:	1035379

    Here is a link to the help guide that shows the various method overloads: https://ninjatrader.com/support/help...rticalline.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Paul. I don't see attachment, did you attach it?
      1. By the way, I dont need a vertical line, but simply a line. Here is my screen.
      2. Can you also help me find how to draw the forward and backward triangles, to show the open and close price?
      Click image for larger version

Name:	Screen Shot 2018-10-12 at 6.52.52 AM.png
Views:	95
Size:	201.9 KB
ID:	1035413

      Comment


        #4
        Hello Shai Samuel,

        Thanks for your post.

        The attachment I mentioned was an incorrect term as I meant the embedded picture that shows the vertical line between bars based on the code shown in the picture itself.

        You do not have to use Draw.VerticalLine, you can use Draw.Line() as it also has method overloads that are based on time so you can use the same time process I advised. For reference here is the link to Draw.Line(): https://ninjatrader.com/support/help...?draw_line.htm

        The Draw.Triangle() would allow you to draw any "multi bar" type triangle however you need a triangle that fits in a single bar width. The easiest approach here is to use Draw.Text() and either use the < or > characters, or to change the font to a symbol type of font such as WingDings 3 that offers a variety of left/right triangles. The advantage of this method is that you are free to use just about any font size making the triangles as large or small as you wish. Here is an example:

        Draw.Text(this, "upper"+CurrentBar, true, "u", 0, High[0] + TickSize, 0, Brushes.OrangeRed, new SimpleFont("Wingdings 3", 10), TextAlignment.Right, Brushes.Transparent, Brushes.Transparent, 0); In this example the character "u" represents the symbol of a filled right-facing triangle in the font family Wingdings 3, draw at a font size of 10.

        Reference:


        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_PaulH View Post

          Reference:
          ninjatrader.com/support/helpGuides/nt8/en-us/?draw_text.htm
          ninjatrader.com/support/helpGuides/nt8/en-us/?simplefont_class.htm
          I'm curious why the links in a lot of the posts from support are incorrect.
          When I 'quote' the post the links show correctly but when clicked on they are invalid.
          i.e. the ones in the post above if clicked on actually go to a "Page not found' instead of the proper url.
          I have pasted the links below that are in that post.

          https://ninjatrader.com/support/helpGuides/nt8/en-us/?draw_text.htm&_gl=1*1x7iga1*_gcl_au*MTc3NzY3ODE2L jE3MDY2NjM2MDIuODI1NjEyMzIyLjE3MDc0MTQ3NTUuMTcwNzQ xNDc1NQ..

          https://ninjatrader.com/support/helpGuides/nt8/en-us/?simplefont_class.htm&_gl=1*1x7iga1*_gcl_au*MTc3Nz Y3ODE2LjE3MDY2NjM2MDIuODI1NjEyMzIyLjE3MDc0MTQ3NTUu MTcwNzQxNDc1NQ..
          Last edited by DavidHP; 03-09-2024, 02:52 PM.

          Comment


            #6
            Hello DavidHP,

            Thanks for your notes.

            We are aware of the behavior regarding links in the forums leading to a 'Page not found' webpage and the Development team is investigating this. I have added this forum thread as impact so the Development team is aware of this happening on this thread.

            That said, I have reposted the links in question below for you to view.

            Draw.Text(): https://ninjatrader.com/support/help.../draw_text.htm

            SimpleFont: https://ninjatrader.com/support/help...font_class.htm
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Gerik, Today, 09:40 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by RookieTrader, Today, 09:37 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by alifarahani, Today, 09:40 AM
            0 responses
            5 views
            0 likes
            Last Post alifarahani  
            Started by KennyK, 05-29-2017, 02:02 AM
            3 responses
            1,284 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by AttiM, 02-14-2024, 05:20 PM
            11 responses
            186 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X