Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninjatrader crashes when drawing lines way outside the screen

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

    Ninjatrader crashes when drawing lines way outside the screen

    FYI

    I developed a market geometry drawing tool which draws many lines on the screen.. These lines could extend into the future and the end points of these
    lines could have coordinates which where outside the chart resolution. Doing so however seems to crash ninja without any log/exception/..... but not always and not on all computers.
    Perhaps its related to video card or driver since i could not get it to crash on some pcs.. but it did crashed constantly on others

    Anyway i had to implement a cohen sutherland algorithm to make sure all my lines where clipped to the chart to fix the crashes
    IMO ninja should not crash randomly when drawing stuff outside the screen, so this may be something to mention to the developers

    My solution:
    Code:
    void DrawLine(ChartControl chartControl, ChartScale chartScale, Vector2 p1, Vector2 p2, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
    {
       chartPanel = chartControl.ChartPanels[chartScale.PanelIndex];
       viewport = new RectangleF(chartPanel.X, chartPanel.Y, chartPanel.W, chartPanel.H);
       points = ClipToviewPort(viewport, p1, p2);
       if (points != null)
       {
           RenderTarget.DrawLine(points.Item1, points.Item2, brush, strokeWidth, strokeStyle);
       }
    }
    EB Worx
    NinjaTrader Ecosystem Vendor - EB Worx

    #2
    Hi Erwin, thanks for your post.

    Are you watching the performance of the video card when testing on different machines? If the problem happens on lower-end machines it might be performance issues related to the SharpDX code.

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello Erwin Beckers,

      Crashes seen when rendering outside of drawing space is not atypical for Directx applications. The same can be said when using SharpDX. We recommend using ChartBars.FromIndex and ChartBars.ToIndex to limit drawing to what is visible, and we also advise using ChartPanel coordinates if a drawing should end up going our of rendering space.

      Implementing your own clipping code may be a bit of overkill, but if it gets the job done that's great and we are happy you have shared your tip.

      We look forward to assisting.
      JimNinjaTrader Customer Service

      Comment


        #4
        Thank Jim

        I don't agree on crashes being typical for DirectX applications when rendering outside the drawing space.
        In my opinion Ninja trader should be as stable as possible and not allow rendering anything outside the drawing space and thus.. do the clipping for us.
        You cannot expect each and every developer to do clipping in their drawing tools / indicators? I've been developing for over 20 years now and its a best practice as a developer to expect the unexpected and handle as much of these cases to get the most stable product. So yes.. i fixed it myself now by implementing clipping.. but i'm pretty sure nobody else is doing this.
        So its just matter of time some user out there will get a crash because some developer did not implement this clipping in his indicator/drawingtool/strategy and accidentally draws something outside the drawing space.


        EB Worx
        NinjaTrader Ecosystem Vendor - EB Worx

        Comment


          #5
          Hello Erwin,

          Indicators and drawing tools are clipped to the indicator panel. I use some code to break out out of the clipping rectangle in my VerticalLineAllPanels drawing tool. (This is very unsupported but does enough to get the job done for non IsInHitTest render passes.)



          The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

          So in addition to this clipping, you want to have NinjaTrader make additional checks for rendering that is out of bounds? We would still suggest only drawing within the viewable space using ChartBars.FromIndex/ChartBars.ToIndex and using ChartPanel coordinates, but we could submit a feature request to provide some other reporting if drawing is done outside of the rendering space. Let me know if that sort of request satisfies your requirement.

          We look forward to assisting.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Skifree, Today, 03:41 AM
          1 response
          2 views
          0 likes
          Last Post Skifree
          by Skifree
           
          Started by usazencort, Today, 01:16 AM
          0 responses
          1 view
          0 likes
          Last Post usazencort  
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          603 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          6 responses
          23 views
          0 likes
          Last Post xiinteractive  
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          23 views
          0 likes
          Last Post Pattontje  
          Working...
          X