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

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 funk10101, Today, 09:43 PM
        0 responses
        3 views
        0 likes
        Last Post funk10101  
        Started by pkefal, 04-11-2024, 07:39 AM
        11 responses
        36 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Yesterday, 08:51 AM
        8 responses
        44 views
        0 likes
        Last Post bill2023  
        Started by yertle, Today, 08:38 AM
        6 responses
        26 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        24 views
        0 likes
        Last Post algospoke  
        Working...
        X