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

Chart is constantly rerendered on left mouse click and hold down.

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

    Chart is constantly rerendered on left mouse click and hold down.

    Hello

    Chart is constantly rerendered on just left mouse click and hold down.
    Total 22 times!
    I dont have OnMouseDown() events attached or MouseLeftClicked().

    Code:
    41793104 OnRenderTargetChanged - creating graphics
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRenderTargetChanged - creating graphics
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    41793104 OnRender - start idx[31..34]
    41793104 OnRender - end
    PHP Code:
                Print(string.Format("{0} OnRender - start idx[{1}..{2}]"GetHashCode(), ChartBars.FromIndexChartBars.ToIndex)); 

    #2
    Hello ren37,

    Yes, this would be expected, Mouse actions or moving the chart bars will cause it to re-render. The Render loop is set to re-render if specific actions have been completed in the chart, one of which would be moving the mouse and bars on the chart.


    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      But I don't move mouse at all, just holding down left button!!!

      Comment


        #4
        Hello,

        Thank you for the reply.

        The OnRender overload gets called for many reasons and not just the mouse, it would be expected that this gets called very frequently while using a chart. Are you seeing a problem and that is why you had posted about this or did you have a specific question related to Rendering other than you see quite a few render passes?

        I would expect that you get a lot of prints while using OnRender for not only mouse actions but for other events that the platform utilizes. If you have a sample script you can provide that demonstrates a specific problem you are having with the rendering I would be happy to review that sample.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          If my indicator takes about 100ms to render so 100 x 22 will be 2.2 sec.
          That's the time passed before the platform starts to scroll chart.
          Click and hold - 22 times render (2 seconds) - move mouse - it starts scrolling.
          That's the problem.
          No data feed connected. So chart not need to be re rendered.
          But if I scroll chart by mouse scroller it renders without intial multuple rendering! Left/right keyboard keys work also perfect.

          Also I have found that if I click on chart window caption "Chart", chart re rendered 8 times.
          Try it at your end. Will check it at my end with dummy indicator tomorrow.
          Last edited by ren37; 03-30-2017, 04:05 PM.

          Comment


            #6
            Hello,

            Thank you for the reply.

            If your render logic is taking a very long time I could only suggest either adding logic to account for the actions that cause the slowdown, or to reduce the logic to be more efficient on each render. As noted the platform will render for many reasons so it would produce a sluggish result in some situations if your render logic takes a long time due to many render passes.

            You could look into using the window and its mouse events to know when you are dragging the mouse to prevent your logic from running. This would be one example of using logic to account or a slowdown. This would not necessarily be the approach I would suggest, though. If the script becomes sluggish while scrolling but other items that use OnRender do not such as Drawing Objects, this may be a problem with the overall logic being used.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi!

              Tested this on dummy indicator with big bar spaces.
              Minimal chart scroll portion equals to bar space. So you must hold and move mouse horizontally more than this value to shift bars. This is good for perfomance reasons. BUT! Al this time indicator OnRender() invoked. So static chart picture re rendered multiple times without any reason. In my oppinion it's a bad design or just a bug.

              What your developers said about that?
              Last edited by ren37; 03-31-2017, 08:24 AM.

              Comment


                #8
                NinjaTrader_Jesse,

                Multiple re rendering on mouse down is related with binding indicator properties to WPF controls.
                Tell that platform developers.

                PHP Code:
                        // INotifyPropertyChanged interface
                        
                event PropertyChangedEventHandler PropertyChanged;

                        protected 
                void OnPropertyChanged(string info)
                        {
                            
                PropertyChangedEventHandler handler PropertyChanged;
                            if (
                handler != null)
                            {
                                
                handler(this, new PropertyChangedEventArgs(info));
                            }
                        } 
                Last edited by ren37; 04-01-2017, 01:25 PM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by lorem, Today, 09:18 AM
                1 response
                4 views
                0 likes
                Last Post lorem
                by lorem
                 
                Started by bmartz, Today, 09:30 AM
                0 responses
                3 views
                0 likes
                Last Post bmartz
                by bmartz
                 
                Started by GussJ, 03-04-2020, 03:11 PM
                14 responses
                3,244 views
                0 likes
                Last Post GussJ
                by GussJ
                 
                Started by ArkansasClint, Today, 09:28 AM
                0 responses
                0 views
                0 likes
                Last Post ArkansasClint  
                Started by hazylizard, Today, 08:38 AM
                4 responses
                12 views
                0 likes
                Last Post hazylizard  
                Working...
                X