Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Graphics Without Clearing Chart

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

    Adding Graphics Without Clearing Chart

    I have an indicator that creates graphics for each bar (only 6 are displayed). On each new tick it is necessary to repaint the graphics for the current bar, but there is usually nothing changed and no need to redraw the graphics for the earlier bars. I have tried using "if first tick of bar" to only redraw the graphics for earlier bars when a new bar gets created, and this works in the sense that the graphics do get drawn. However they get erased when the next tick comes in.

    I cannot figure out where the screen graphics get erased. If I could inhibit the erase, I think I could save a lot of processing cycles.

    Where are the screen graphics erased when the new tick arrives and I initiate drawing the graphics for the new tick?
    Last edited by HNWtrader; 09-04-2010, 07:26 PM.

    #2
    HNWtrader, what NinjaScript methods are working with in this context?

    BertrandNinjaTrader Customer Service

    Comment


      #3
      The starting point for the indicator is the NinjScript "VolumeProfile". The basic idea is to create a similar profile for each of several recent price bars. The changes that I made include the addition of several variables, mostly in "#region Variables". Other than that, the bulk of the changes were made to the method "OnBarUpdate()" and the method "Plot(...)".

      There are a number of lines added to "OnBarUpdate()" within an "if (FirstTickOfBar)" that are basically shifting parameters associated with each bar back one position as each new bar is created. Most of these are related to establishing the correct width of the profile graphics, and recording a separate "SortedDictionary" like "volumeInfo" for each bar. Ultimately I hope to be able to scroll back on a chart and have this information available for every bar, but for now I just keep records for six bars.

      The changes made to "Plot(...)" include additional graphics, similar to the original code, but since I am drawing six separate profiles, I created a method called by "Plot(...)" six times, once for each bar's profile. I also found it necessary to move the code used to find the maximum volume for the profile out of the method "Plot(...)" into "OnMarketData(...)", because if a chart window is minimized or covered by another window, the code within "Plot(..)" is not executed, and that destroys my graphics formatting. (Inhibiting this code when the chart is minimized is a good thing for reducing processor load, but I need to have the formatting parameters updated on every tick.)

      All of this works fine, but I am hoping to reduce the processing load by redrawing the 5 older profiles only when an event introduces a shift in their location on the screen. This of course happens at the beginning of a new bar, and it will also happen if the current bar, or an adjustment of the vertical scale, causes a shift up or down or a change in vertical range (change of the variables "max" or "min"). I do not know what is erasing these older profiles at each par update. Perhaps it is in the code that draws the bars. If that is the case, there may be nothing I can do about it, but that code would likely be more processor efficient if it only repainted earlier bars when they needed to be moved.

      Comment


        #4
        Thanks for clarifying HNWtrader - unfortunately the custom drawing methods used in this indicator are not supported in a sense that we don't have them documented and as such can't provide support for them being used - perhaps other forums members can add their take here if they are familiar with those as well.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          cordell - unfortunately we would not be able to provide you with trading advice or recommendations.
          BertrandNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by samish18, Today, 01:01 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by WHICKED, Today, 12:56 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cre8able, Today, 01:16 PM
          0 responses
          3 views
          0 likes
          Last Post cre8able  
          Started by chbruno, 04-24-2024, 04:10 PM
          2 responses
          47 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by WHICKED, Today, 12:45 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X