Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw rectangle to Top (or Bottom) of Chart

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

    Draw rectangle to Top (or Bottom) of Chart

    This example (long condition)

    DrawRectangle("RectUp", false, 1, Open[0], 0, Close[0], Color.Transparent, Color.Green, 2);

    draws a nice rectangle one bar ago to current bar (horizontal) from Open to Close (vertical).

    With what would I have to replace "Close[0]" to have the rectangle instead extend to the top of the chart?

    sandman

    #2
    hello,

    Thank you for the question.

    I am unsure of a way to get the price from specifically the top of the current scale for a drawing tool. I will need to review this further. There are some items to account for with drawing objects because this would not get updated unless it was called again. As the scale can change the price would change as well depending on the data displayed. OnBarUpdate would likely be used to call the DrawRectangle again to update it.

    Generally if you are trying to draw from the chart panel, rather than price values x and y coordinates are used. For this you could draw from a X and Y value to a converted price to Y point. For an example of this please see the indicator in the platform CustomPlotSample

    When using a drawing tool I could suggest using items like the CurrentDayOHL to get the High but this may not include the highest point on the chart. Further logic could be added to include the visible region of the chart to make it more constant but it would still not be the charts top.

    I look forward to being of further assistance.

    Comment


      #3
      Jesse. Thanks.

      Not sure I understand exactly what you are saying.

      I have also tried this which extends the rectangle vertically starting at the Open Price (which is always a stable value) and I have to manually tell it by how many ticks:

      DrawRectangle("RecUp", false, 1, Open[0], 0, Open[0] + offset * TickSize, Color.Transparent, Color.Green, 2);

      I could set it to 100 or 200 and it would most always hit the top of the chart - perhaps with the exception of Brexit or Trump days

      What do you mean with the "indicator in the platform CustomPlotSample"? Where do I find this?

      sandman

      Comment


        #4
        Hello,

        This is a indicator that comes with the platform called CustomPlotSample, it just shows the alternative way to draw on the chart. This is the suggested way to draw when actual panel coordinates are wanted such as the top of the chart panel or bottom.

        Otherwise if Prices would suite the need, you could call the CurretDayOHL indicator to get the days High and Low and then adjust an offset from that point as well. http://ninjatrader.com/support/helpG...nt_day_ohl.htm

        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        563 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        329 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X