Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic Support and Reststance support lines question

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

    Dynamic Support and Reststance support lines question

    Scenario:

    I want to dynamically draw/show support/resistance lines using some drawing object/technique (rectangle/region/line/plot). I will calculate and draw them dynamically but the "levels/prices" could change thru the chart as the prices change through the session. I don't know how many different 'lines/prices' I will draw for a session in advance. Some prices may be in place the entire session and others may come and go. I want the drawing objects to remain displayed in history on the chart so I can review them for analysis later.

    Question:
    What is my most efficient method of drawing to show these dynamic "prices/levels" as the price moves? If I draw rectangles I will need to redraw each object name on each bar close as the rectangle gets longer as it remains in effect. Then if the price comes back into effect I need to assign a new name so I don't remove history by redrawing the same name. I restart my calculations with each new session, If the chart goes back many days I could end up with quite a few drawing objects and was concerned about a performance impact. I was thinking draw a rectangle initially to the end of the session then redraw it shorter ending only if it the "line/price" goes out of effect to reduce the drawing overhead if the price is no longer in effect. Longer code path but more efficient on resources. Thought of using plots (which I consider efficient) but I would be forced to create a fix number of plots in advance. My indicator allows you to select the closest SR prices within "X" ticks of the last close price so the "lines" can change frequently but might not. I also considered the use of regions and data series but an again need to allocate a fixed number in advance,

    I use an added time frame for a timing trigger on when to recalculate the "lines" as they are a pig. (aka resource intensive). In this way you can be on a 15 minute chart but recalculate/redraw the dynamic "lines" more frequently.

    Great wizards of NinjaScript knowledge I seek wisdom and direction.

    Cheers


    #2
    When you say "the most efficient" there is a difference between fast running and fast to code. The fastest running solution is to keep the current ones in a list, and show them with a custom OnRender(). The fastest to code is to Draw.Rectangle them, and re-draw them when they change. Yes, you can draw to the end of the session, or if you're using bar indices, something like -1000 for the bar index, and change it later. Sometimes people draw them out 1000 bars and then on each bar, redraw them so they're still out 1000 bars and never get there. If time and code length is no object, write a custom OnRender() so you can do this however you want it done.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      QuantKey_Bruce

      Thanks for the feedback. I am using time and not bars for draw anchoring.

      Cheers

      Comment


        #4
        Hello ct,

        Thanks for your notes.

        QuantKey_Bruce has provided some good insight on how this could be accomplished. As they stated, using OnRender() to custom render the objects on the chart would be the fastest-running solution and the quickest solution to code would be to use Draw.Rectangle() to draw the objects on a chart.

        To modify a draw object when using Draw.Rectangle() so that it extends until a certain condition is met, you would need to ensure that you are providing the same tag name to the Draw method. Then, when you want a new object drawn on the chart, you would use a unique tag name for the Draw method.

        Using SharpDX for Custom Chart Rendering: https://ninjatrader.com/support/help..._rendering.htm
        OnRender: https://ninjatrader.com/support/help...8/onrender.htm
        RenderTarget.DrawRectangle: https://ninjatrader.com/support/help...wrectangle.htm

        Draw.Rectangle(): https://ninjatrader.com/support/help..._rectangle.htm

        Below is a link to a 3rd party addon drawing tool that provides the functionality of extending a rectangle which you might find helpful.
        https://ninjatraderecosystem.com/use...rom-all-sides/
        Last edited by NinjaTrader_BrandonH; 05-07-2023, 05:42 PM.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          I have manually drawn few support and resistance zones(rectangle drawing objects) on a chart(spy, 3minute), and as the day session begins(9:30 AM est) - i would like to know if the price hits the support/resistance zones on close of a 3m candle bar. How do i write the code for it?

          Comment


            #6
            Hello psangram,

            Thanks for your notes.

            I see you have posted this question on another forum thread.

            Please see the answer on this forum thread in regards to your question: https://forum.ninjatrader.com/forum/...70#post1279470
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              The sr lines have Huge text description to the right Hoe can I remove this trxr??

              Comment


                #8
                Hello wisconsinpat,

                Thanks for your notes.

                To clarify, is this an indicator that you programmed yourself or are you referring to an indicator that comes default with NinjaTrader?

                Or, are you referring to using a Drawing Tool?

                If this is an indicator that comes default with NinjaTrader, what is the name of the indicator?

                If this is an indicator you programmed, how exactly are you drawing text on the chart? Is this done with Draw methods or custom rendering in OnRender()?

                Please send us a screenshot of the indicator line text you are referring to so we may see what you are seeing.
                • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
                • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jxs_xrj, 01-12-2020, 09:49 AM
                5 responses
                3,290 views
                1 like
                Last Post jgualdronc  
                Started by Touch-Ups, Today, 10:36 AM
                0 responses
                7 views
                0 likes
                Last Post Touch-Ups  
                Started by geddyisodin, 04-25-2024, 05:20 AM
                8 responses
                61 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by Option Whisperer, Today, 09:55 AM
                0 responses
                8 views
                0 likes
                Last Post Option Whisperer  
                Started by halgo_boulder, 04-20-2024, 08:44 AM
                2 responses
                24 views
                0 likes
                Last Post halgo_boulder  
                Working...
                X