Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Constraining the number of bars on a chart

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

    Constraining the number of bars on a chart

    Is there any way to constrain the number of bars on a chart? I'm working with fast tick charts and indicators that use shading via Draw.Region(). The chart gets slower as more bars get added until it freezes.

    #2
    Hello kevinenergy,

    Thank you for the post.

    The only constraint would be when you first load data, you can choose a period of time or number of bars. After that point, new bars would form but would not remove old bars from the chart.

    When using drawing objects, if you are creating many regions for short spans that would take more resources. One approach may be to try to instead use less regions that span more bars by using logic. Drawing tools can be updated using their Tag, so this is one option.

    The best solution will be to use OnRender. When using OnRender, you can draw what you wish over the visible bars on the chart only. This does not have an object associated with it so it would be more efficient than many drawing objects. This does, however, require that you come up with some logic to put in place of the drawing objects to collect that data for later rendering.

    You can find more information on OnRender by opening the SampleCustomRender indicator.

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

    Comment


      #3
      Thank you for the response Jesse. I've done some stuff with OnRender() so I'm familiar. Can you provide a very simple example of region shading? For example the area between two moving averages like in the attached screenshot.... how could I achieve this via OnRender?

      I have drawn text, lines and rectangles using OnRender - its awesome. But I literally don't know where to start to shade a complex region such as between two moving averages.

      Any advice you can give would be greatly appreciated.

      Thanks for the brilliant support!
      Attached Files
      Last edited by kevinenergy; 09-07-2018, 04:08 PM.

      Comment


        #4
        Hello kevinenergy,

        Thank you for the reply.

        Yes, making a region in SharpDX would be more complex but would be more efficient than many little objects. The other alternative which is still valid is to use more logic to expand the region tools you use to encompass more bars thus creating fewer objects. I understand if the goal wasn't to allow for spanning multiple bars so I wanted to provide a few options for you to think over. Your image seems to indicate that updating the existing regions may be an option so you might take a look at the following item:

        This indicator uses logic to store bars which the regions use much like your image.

        The best example for drawing in sharpdx for a region would likely be the Region or the Polygon tools that come with the platform. The region already uses two series for shading a region and shows essentially what would be required to draw a path geometry from OnRender. The reason I suggested this would be if the goal is actually to have many little regions and spanning multiple bars is not an option, OnRender would be more efficient at that specifically.

        PathGeometry is used for SharpDX which is more of a general rendering concept shared by it and Direct2d. You can find other useful resources explaining in more detail how path geometry works online as well.

        I look forward to being of further assistance.
        Last edited by NinjaTrader_Jesse; 09-10-2018, 07:50 AM.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by love2code2trade, Yesterday, 01:45 PM
        3 responses
        22 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by trilliantrader, Today, 08:16 AM
        2 responses
        6 views
        0 likes
        Last Post trilliantrader  
        Started by samish18, Today, 08:31 AM
        1 response
        1 view
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by Creamers, 09-08-2023, 10:26 AM
        6 responses
        157 views
        0 likes
        Last Post JonyGurt  
        Started by funk10101, Today, 08:14 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X