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

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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, Today, 06:53 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottWalsh, Today, 06:52 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottW, Today, 06:09 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ftsc2022, 10-25-2022, 12:03 PM
        5 responses
        256 views
        0 likes
        Last Post KeyonMatthews  
        Started by Board game geek, 10-29-2023, 12:00 PM
        14 responses
        244 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Working...
        X