Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Overlapping and interconnected Regions

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

    Overlapping and interconnected Regions

    Hello,

    I am working on building an indicator to plot zones for a given day that are read from a file that matches the instrument + date stamp. See attached screenshot of the general idea of how I would imagine the plots to look.

    I planned on using Draw.Region since it seemed to handle historical and future plots. Each day is expected to be a separate region. I don't want any interconnected lines between different days zones. My understanding of the documentation for Region is that if I supplied a unique tag a new region would be created otherwise the existing region with the same tag would be modified.

    I am seeing behavior that leads me to think my understanding of the above is incorrect or my usage is incorrect (See overlapping_zones.png):
    - Subsequent day's zones all start from the first day's zones. Note that the opacity increases and that Day 2's zones have a red border and start from Day 1.
    - Zones connect in the midst a missing day (Day 3)

    I now suspect that using ISeries to store the data is what is causing all the regions to start from the first bar plotted.

    Code here for syntax highlighting: https://pastebin.com/Lb7Y5wP1

    --Ryan
    Attached Files

    #2
    Resetting zone1a through zone12b to a new Series after line 179 made it work, but still feel like I am using the wrong drawing tool. I see how Drawing.Line takes doubles as arguments, but I want a shaded region since it is visually more obvious.

    Is there any performance harm to re-initializing a new Series once a new day is encountered?
    Attached Files

    Comment


      #3
      Hello ryanswood,

      Thanks for opening the thread.

      Draw.Region() takes a Series<double> as input to create an amorphous shape that fills the region between the bounds of the Series<double>'s. For example, a region can be used to create a cloud over the region between the High and Low values of a chart.

      Looking at your code, you are loading some data and adding it to the current bar for the associated Series<double>. This creates a Series<double> with all of the necessary points with each iterating OBU. Without breaking off the previous data from a previous day by resetting the Series<double>, you will include the previous region in your shape.

      If you want to use Draw.Region(), resetting the Series<double> will be necessary to break off a new shape. If you only want to focus on rectangles, and not consider any amorphous shapes, I would suggest to use Draw.Rectangle() instead. This way, so you can manage your shapes using a fixed number of doubles rather than Series<double>'s to reduce memory footprint.

      Draw.Rectangle() - https://ninjatrader.com/support/help..._rectangle.htm

      Please let me know if I can be of further assistance.
      JimNinjaTrader Customer Service

      Comment


        #4
        Thank you for the background on Region. It makes total sense and is now obvious. I was able to use Rectangle instead after a few attempts of the various method signatures. The code is much cleaner and shorter. Thank you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by RookieTrader, Today, 09:37 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by alifarahani, Today, 09:40 AM
        0 responses
        5 views
        0 likes
        Last Post alifarahani  
        Started by Gerik, Today, 09:40 AM
        0 responses
        4 views
        0 likes
        Last Post Gerik
        by Gerik
         
        Started by KennyK, 05-29-2017, 02:02 AM
        3 responses
        1,283 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by AttiM, 02-14-2024, 05:20 PM
        11 responses
        185 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X