Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Region slow when scrolling mouse wheel

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

    Draw.Region slow when scrolling mouse wheel

    When a chart has a lot of data, for example: around 100 days of 1 minute data for a 9:30 to 4pm issue, and using Draw.Region in an indicator, there is a considerable difference in speed when scrolling the chart with the mouse wheel (it's slow!).

    It's starts to seriously degrade. Removing the indicator - everything is back to normal.
    Not really noticeable on small data sets (5 days of 1 minute), although some 'drag' can be sceen, but still at an acceptable speed.

    Moving the slider is instant and fast.

    I doubt it is related to the public Series<double> use...

    Enabling global crosshairs and using a 2nd chart to scroll the first chart is faster.



    MSI 15.6" WQHD+ 3K Mobile Workstation
    with Intel Core i7-4810MQ (2.7 Ghz),
    NVIDIA Quadro K3100M w/ 4GB GDDR5 VRAM
    and Windows 7 Professional

    The code here is pretty simple:


    #2
    Thanks for the report. This falls under the general performance issues we have outstanding and will be worked on throughout beta. This is a good test though and would love to hear feedback with each beta release to see if there any improvements from the end user perspective.
    MatthewNinjaTrader Product Management

    Comment


      #3
      DrawRegion causes chart freeze (Beta 8.0.0.5)

      I have coded a little test indicator which plots 3 Bollinger Bands around a moving average and fills the areas between the bands with DrawRegion().

      My test chart is a 1-min chart with a lookback period of 100 days. Adding the indicator to the chart takes

      NinjaTrader 7 without filling the areas: < 1 second
      NinjaTrader 8 without filling the areas: < 1 second
      NinjaTrader 7 with areas filled via DrawRegion(): 13 seconds
      NinjaTrader 7 with areas filled via a custom plot: 1 second
      NinjaTrader 8 with area filled via DrawRegion(): 10 seconds

      The problem here is that with a lookback period of 150 days, the chart is virtually frozen.

      Vertical compression: Movements are rough and irregular. It is impossible to select the compression as needed.

      Horizontal scrolling or compression: Takes ages, irregular and rough.

      The problem depends on the lookback period. If I reduce the lookback period to 3 days, the freeze goes away. My conclusion: When scrolling or compressing the chart, the entire lookback period (150 days) seems to be recalculated, although it would be sufficient to recalculate the visible part of the chart.

      I would love to attach a screenshot, but

      NinjaTrader 8 saved the PNG chart with a resolution of 1934 x 1259
      Forum Limitation is 1920 x 1200 for PNG

      Last edited by Harry; 09-24-2015, 05:27 PM.

      Comment


        #4
        Draw.Region causes high CPU load and freeze when connected to data feed

        I have added that simple indicator with Draw.Region to my chart again, and when setting the chart to "OnPriceChange", CPU load was increased drastically. NinjaTrader did not respond properly to mouse clicks and opening of popup menus was delayed.

        Tested on a quad core XEON processor. Below are screenshots taken from the CPU load of the four kernels. Both screenshots show NinjaTrader 8 with a single chart open, with a single indicator applied.

        The first chart shows CPU load with Draw.Region active. The second chart shows the same indicator with Draw.Region deactivated (option available in the indicator). As you can see a single chart with Draw.Region applied makes NinjaTrader next to unusable. At the current stage this is much worse than the behavior of NinjaTrader 7.

        The GPU is not used.
        Attached Files
        Last edited by Harry; 09-25-2015, 01:14 PM.

        Comment


          #5
          The CPU load also depends on the lookback period of the chart.

          Draw.Region recalculates over the entire chart period for each incoming tick.

          Obviously, this will kill any CPU, if there are enough bars on the chart.

          Comment


            #6
            Thanks for the detailed report. There are definitely some performance improvements in this area we have scheduled as we do ongoing maintenance throughout beta. I'm going to check with development on your scenario to see where we are.

            Just so we're looking at apples to apples, can you provide the script you are testing with?

            Or can you clarify how you've implemented Draw.Region? When you say that you are drawing the areas between the bands, is this through one instance (e.g., using one tag) for the whole series? Or are you drawing on multiple bars and creating new instances?
            MatthewNinjaTrader Product Management

            Comment


              #7
              Originally posted by NinjaTrader_Matthew View Post
              Thanks for the detailed report. There are definitely some performance improvements in this area we have scheduled as we do ongoing maintenance throughout beta. I'm going to check with development on your scenario to see where we are.

              Just so we're looking at apples to apples, can you provide the script you are testing with?

              Or can you clarify how you've implemented Draw.Region? When you say that you are drawing the areas between the bands, is this through one instance (e.g., using one tag) for the whole series? Or are you drawing on multiple bars and creating new instances?
              I have basically taken the Bollinger indicator, added two more channels and then used Draw.Region() to fill the segments between the channels.

              I have used one tag for the entire series. Otherwise it would take over a minute to load the indicator, and CPU load would be further increased.

              Code:
                          if(Opacity3 > 0)
                          {    
                              Draw.Region(this,"UB3", CurrentBar , 0, Upper3, Upper2, transparentBrush, OuterAreaBrush, Opacity3);
                              Draw.Region(this,"LB3", CurrentBar , 0, Lower2, Lower3, transparentBrush, OuterAreaBrush, Opacity3);
                          }
                          if(Opacity2 > 0)
                          {    
                              Draw.Region(this,"UB2", CurrentBar , 0, Upper2, Upper1, transparentBrush, MidAreaBrush, Opacity2);
                              Draw.Region(this,"LB2", CurrentBar , 0, Lower1, Lower2, transparentBrush, MidAreaBrush, Opacity2);
                          }
                          if(Opacity1 > 0)
                          {    
                              Draw.Region(this,"UB1", CurrentBar , 0, Upper1, Middle, transparentBrush, InnerAreaBrush, Opacity1);
                              Draw.Region(this,"LB1", CurrentBar , 0, Middle, Lower1, transparentBrush, InnerAreaBrush, Opacity1);
                          }
              Indicator is attached.
              Attached Files
              Last edited by Harry; 09-25-2015, 02:51 PM.

              Comment


                #8
                Originally posted by Harry View Post
                I have basically taken the Bollinger indicator, added two more channels and then used Draw.Region() to fill the segments between the channels.

                I have used one tag for the entire series. Otherwise it would take over a minute to load the indicator, and CPU load would be further increased.

                Code:
                            if(Opacity3 > 0)
                            {    
                                Draw.Region(this,"UB3", CurrentBar , 0, Upper3, Upper2, transparentBrush, OuterAreaBrush, Opacity3);
                                Draw.Region(this,"LB3", CurrentBar , 0, Lower2, Lower3, transparentBrush, OuterAreaBrush, Opacity3);
                            }
                            if(Opacity2 > 0)
                            {    
                                Draw.Region(this,"UB2", CurrentBar , 0, Upper2, Upper1, transparentBrush, MidAreaBrush, Opacity2);
                                Draw.Region(this,"LB2", CurrentBar , 0, Lower1, Lower2, transparentBrush, MidAreaBrush, Opacity2);
                            }
                            if(Opacity1 > 0)
                            {    
                                Draw.Region(this,"UB1", CurrentBar , 0, Upper1, Middle, transparentBrush, InnerAreaBrush, Opacity1);
                                Draw.Region(this,"LB1", CurrentBar , 0, Middle, Lower1, transparentBrush, InnerAreaBrush, Opacity1);
                            }
                I cannot attach the indicator script, because NinjaTrader 8 hangs (crash) when I try to export an indicator file.
                Thanks I'll have a look, I appreciate it.

                Regarding the crash, is that always reproducible? Was there an existing bug report on that in B5?
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Originally posted by NinjaTrader_Matthew View Post
                  Thanks I'll have a look, I appreciate it.

                  Regarding the crash, is that always reproducible? Was there an existing bug report on that in B5?
                  In fact it was not a crash. It just had that turning symbol instead of the mouse arrow, but I was still able to click the button and it worked.

                  Comment


                    #10
                    Thanks Harry - we'll be applying some optimizations to the @Reigion class in B6 - NTEIGHT-8867
                    MatthewNinjaTrader Product Management

                    Comment


                      #11
                      DrawRegion with Displacement Bug

                      When DrawRegion() is used with a displacement, the region is not properly filled.

                      For example if a displacement of 20 bars is selected, the region will not be plotted for the first 20 bars on the chart.

                      Below are two samples that show the problem.

                      First chart: Multiple Bollinger Bands with a displacement of 20 bars

                      Second chart: An Ichimoku indicator which uses DrawRegion to plot the Kumo (cloud) forward. When there are less than 26 bars on the chart, the forward section of the cloud is incomplete. (The code only uses the displacement for the forward section of the cloud, but not for the main cloud, which is created from a displaced DataSeries.)
                      Attached Files
                      Last edited by Harry; 05-27-2016, 05:40 AM.

                      Comment


                        #12
                        Hello Harry,

                        Are you using displacement on the Draw.Region call itself?
                        (This would cause the first bars up to the displacement to not be plotted)

                        Draw.Region(this, "region", CurrentBar, 0, Values[0], Values[1], Brushes.Transparent, Brushes.Blue, 9, 20);
                        Draw.Region(NinjaScriptBase owner, string tag, int startBarsAgo, int endBarsAgo, ISeries<double> series1, ISeries<double> series2, Brush outlineBrush, Brush areaBrush, int areaOpacity, [int displacement])

                        If so, this would be the expected behavior when using displacement on the Draw.Region() object. The bars up to the displacement number are not plotted and the slots after the last bar will be plotted up to the displacement number.


                        Or are you setting the Displacement of the entire indicator and not using the displacement overload on the draw region?

                        Draw.Region(this, "region", CurrentBar, 0, Values[0], Values[1], Brushes.Transparent, Brushes.Blue, 9);



                        With the entire indicator set with Displacement this should not cause the region to be displaced. This should only displace the plots.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello Harry,

                          Are you using displacement on the Draw.Region call itself?
                          (This would cause the first bars up to the displacement to not be plotted)

                          Draw.Region(this, "region", CurrentBar, 0, Values[0], Values[1], Brushes.Transparent, Brushes.Blue, 9, 20);
                          Draw.Region(NinjaScriptBase owner, string tag, int startBarsAgo, int endBarsAgo, ISeries<double> series1, ISeries<double> series2, Brush outlineBrush, Brush areaBrush, int areaOpacity, [int displacement])

                          If so, this would be the expected behavior when using displacement on the Draw.Region() object. The bars up to the displacement number are not plotted and the slots after the last bar will be plotted up to the displacement number.


                          Or are you setting the Displacement of the entire indicator and not using the displacement overload on the draw region?

                          Draw.Region(this, "region", CurrentBar, 0, Values[0], Values[1], Brushes.Transparent, Brushes.Blue, 9);



                          With the entire indicator set with Displacement this should not cause the region to be displaced. This should only displace the plots.

                          Thank you for your quick answer. Actually there are two different cases.

                          (1) First case (BollingerBands): When I am displacing the Bollinger Bands, I also wish to displace DrawRegion along with it. This is obvious, as otherwise the region would not match the plots. For that purpose I use the displacement feature or DarwRegion. The result is not satisfactory, as part of the area between the plots remains empty.

                          (2) Second case (Ichimoku): In this case it is not the entire indicator which is displaced, but the DrawRegion() is used to plot the cloud forward. But also in this case part of the cloud is missing and as you see from my screenshot, there is a big hole in the middle of the chart.

                          I want to point out that the way the displacement feature has been implemented for DrawRegion(), it is entirely useless. It is NOT working as expected and cannot be used as needed for correctly implementing indicators.

                          Comment


                            #14
                            Hi Harry,

                            I'm actually just now understanding what you were trying to point out.

                            The region is not being displaced from the first actual bar (as in bar 0), it is being displaced from the left side of the rendered area, which would be a bug.

                            When you mentioned in post #11 "For example if a displacement of 20 bars is selected, the region will not be plotted for the first 20 bars on the chart.", I understood this as the first 20 bars from bar 0 will not be plotted, which is the expected behavior.

                            I've put in a bug report about this. Once I have a tracking ID for this bug report I will post this ID in this thread.

                            Thank you for your clarification to get me pointed in the right direction.
                            Last edited by NinjaTrader_ChelseaB; 05-27-2016, 12:54 PM.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Chelsea,

                              That is exactly the point.

                              Thank you for your help.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              3 responses
                              11 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by Johnny Santiago, 10-11-2019, 09:21 AM
                              95 responses
                              6,193 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Irukandji, Today, 09:34 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by RubenCazorla, Today, 09:07 AM
                              1 response
                              6 views
                              0 likes
                              Last Post RubenCazorla  
                              Started by TraderBCL, Today, 04:38 AM
                              3 responses
                              26 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X