Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Event for detecting when chart moves

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

    Event for detecting when chart moves

    Hi,

    I wrote an indicator that draws some rectangles based on user selection. The problem I have is that when the chart shifts left or right (either by user input or more data) the objects stay at their original position naturally.

    Is there an event I can subscribe for, or any other method, that would fire when the chart moves so that I can also re position my custom drawn objects?

    Thanks for any help.
    Last edited by JohnSteinberg; 08-07-2016, 03:20 AM.

    #2
    Hello JohnSteinberg, and thank you for your question.

    Drawing objects have tags associated with them. For example, a signature for Draw.Rectangle looks like this :

    Originally posted by http://ninjatrader.com/support/helpGuides/nt8/en-us/draw_rectangle.htm
    Draw.Rectangle(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush)
    emphasis mine.

    Whenever you call Draw.Rectangle with the same tag again, it will modify the rectangle referred to by that tag rather than drawing a new one. This means that, just as a for instance, you can call this every time you call OnBarUpdate with 5 and 0 for start and end BarsAgo, respectively, to advance a 5 bar wide rectangle forward 1 bar for every bar you advance 1 bar.

    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hi Jessica P,

      Thank you very much for the reply. I think I have found part of my problem. I am drawing the rectangles in the plot override of the indicator with graphics.FillRectangle instead of using DrawRectangle.

      Thanks for your suggestion, I will definitely try it out. I will let you know what I find.

      Kind Regards,
      JohnSteinberg
      Last edited by JohnSteinberg; 08-09-2016, 04:34 AM.

      Comment


        #4
        For anyone that might read this, using DrawRectangle instead of graphics.FillRectangle in the Plot override solved the problem for me.

        Thanks again for your reply Jessica P

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        574 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X