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 termination.

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

    Rectangle termination.

    Hi I have horizontal rectangles drawn on the chart through an indicator and would like them to stop if price closes below(or above) the rectangle.
    If the close is below the start y how can I tell it to terminate the rectangle at that point? Would I need to redraw the rectangle with a new EndBarsAgo specified by the area which closed below the startY? Whats the best way to do this. Thanks.

    #2
    Hello brucelevy,

    Are you using Draw.Rectangle()?

    Are you custom rendering a rectangle in OnRender()?

    Can you clarify what you mean when you say "would like them to stop if price closes below(or above) the rectangle"?

    If the price crosses into the rectangle you would like the rectangle to not be drawn, is this correct?

    Are you trying to set the startY or endY to the current price?

    If you are trying to set the startY or endY to the current price, then yes, you would need to call Draw.Rectangle() and re-use the tagName so the object is re-drawn instead of a new object added and set this to the current Close[0] price.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I was actually using IRectangle.

      Yes I would like the rectangle to terminate if the Close[0] is below the StartY price level. So I imagine I would have to redraw the rectangle from the original StartY to the new EndY where price closed below.

      Should I be using on onrendor?

      Comment


        #4
        Hello brucelevy,

        If you are wanting to terminate the rectangle (as in remove the drawing object) this can be done with RemoveDrawObject().


        Also, I overlooked this was for NinjaTrader 7.

        For NinjaTrader 7 this would be DrawRectangle() (without the dot).
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          If you are going to redraw because your Y parameter has changed you needn't remove it. Just redraw using the Same tag and the new Y paramater and it will adjust your rectangle.

          Comment


            #6
            So if I want to create the condition

            if (Close[0] < StartY)
            {
            DrawRectangle("use same tag name", use new end bars ago);
            }

            How do I store the StartY so it can be referenced and get the new endBarsAgo location once the Close[0] is below the StartY.

            I want the rectangle to be redrawn from the startBarsAgo to the bar at which the Close[0] is below the StartY.

            In this image you can see the red resistance rectangles going through the candles, I'd like the rectangle to stop once the price has closed over the rectangle to represent a violation of the support or resistance level.
            Last edited by brucelevy; 05-17-2017, 10:25 PM.

            Comment


              #7
              Hello brucelevy,

              You can save the rectangle to a variable and access the .StartAnchor.



              You could also save just the CurrentBar or price value used when first drawing the object to a variable and refer to this later.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              41 views
              0 likes
              Last Post alifarahani  
              Started by Waxavi, Today, 02:10 AM
              1 response
              20 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Working...
              X