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

DrawRegion() not producing desired results

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

    DrawRegion() not producing desired results

    I am working on an indicator to shade between two DataSeries, but the DrawRegion() method is not providing the desired results. DrawRegion() shades between the DataSeries, but only analogous to a line plot (see attached .jpg).

    I would like to have the shade be analogous to a Square plot as shown to the right in the attached .jpg.

    There seems to be no way to accomplish this using the DrawRegion().

    I was thinking of using the BackColor property, but there appears to be no means to limit the Back Color to the area between the DataSeries.

    Do any forum members know of an advanced way of accomplishing this by using DrawRegion or BackColor or some other approach?
    Attached Files

    #2
    Does this help?




    Originally posted by h1000 View Post
    I am working on an indicator to shade between two DataSeries, but the DrawRegion() method is not providing the desired results. DrawRegion() shades between the DataSeries, but only analogous to a line plot (see attached .jpg).

    I would like to have the shade be analogous to a Square plot as shown to the right in the attached .jpg.

    There seems to be no way to accomplish this using the DrawRegion().

    I was thinking of using the BackColor property, but there appears to be no means to limit the Back Color to the area between the DataSeries.

    Do any forum members know of an advanced way of accomplishing this by using DrawRegion or BackColor or some other approach?

    Comment


      #3
      Hello h1000,

      Thank you for your post.

      The link Sledge provides here is to a Forum post that suggests using the CustomPlotSample to alter the brush size. This may also prove useful for your in altering the plot of your indicator to the desired plot.

      To view the CustomPlotSample which will provide an example of custom plotting please go to the NinjaTrader Control Center > Tools > Edit NinjaScript > Indicator > CustomPlotSample.

      Please let me know if you have any questions.

      Comment


        #4
        This link does help somewhat, but it raises many issues.

        After studing the example CustomPlotSample indicator, it appears that graphics.FillRectangle draws a rectangle by using coordinates within the window itself. For instance, coordinates of 0,0,200,200 will draw a rectangle starting at the top left corner of the window (0,0) that is 200 pixels wide and 200 pixels high. This brings to mind all sorts of complexities that one would encounter with chart scaling. One would not only have to calculate the exact pixel coordinates for each rectangle, but because the rectangles are drawn on the window, rather than “directly” on the chart, every rectangle would be to be redrawn with each new bar. This becomes even more problematical if one were to drag the chart left or right. Since the rectangles are drawn on the window, rather than directly on the chart, the rectangles would not automatically move with the chart.

        Also, it appears that a rectangle drawn using the graphics.FillRectangle method is drawn on top of the price bars, which is quite a problem. Could this be corrected?

        If I only wanted to only draw single a rectangle one the current bar, I could see using the graphics.FillRectangle method. But applying this method to every single bar in a chart, seems (at least to me) not to be the most practical solution.

        Am I reading this situation correctly, or am I overlooking something that would mitigate these concerns?

        Comment


          #5
          Hello h1000,

          Thank you for your response.

          There is no documentation on overriding the plot method or custom plotting. However, you can find information on finding the y value of a bar using the information at the following link, this will be used similarly to finding the x value as well: http://www.ninjatrader.com/support/f...ad.php?t=23979

          Comment


            #6
            Patrick,

            Thanks for the link, I will study it.

            Comment


              #7
              (NT Administrators: I realize this is not the most ideal means of communicating, but I hope you will bear with me as the PM service seems to be having difficulties).

              Koganam,

              As the private messaging service is not working correctly, I will make my request directly in the forum.

              I have contacted you many times on programming matters and have always found your advice to be insightful. It seems that the graphics.FillRectangle method might work, but might also be frought with difficulties. If you have the time, could take a look at this thread and see what you think. I would be grateful for any thoughts, suggestions and advice you might have on this topic.

              Comment


                #8
                Originally posted by h1000 View Post
                (NT Administrators: I realize this is not the most ideal means of communicating, but I hope you will bear with me as the PM service seems to be having difficulties).

                Koganam,

                As the private messaging service is not working correctly, I will make my request directly in the forum.

                I have contacted you many times on programming matters and have always found your advice to be insightful. It seems that the graphics.FillRectangle method might work, but might also be frought with difficulties. If you have the time, could take a look at this thread and see what you think. I would be grateful for any thoughts, suggestions and advice you might have on this topic.
                The last page of this document: http://www.ninjatrader.com/support/h...er_11_2010.pdf will show you how to iterate through bars and how to determine x and y values. you will need to feed these to a method that you call in the Plot() method. (Coding it directly in the Plot() method, while viable, is probably not best coding practice).

                Comment


                  #9
                  Koganam,

                  Thanks very much for this information! I will look through it carefully and hopefully be able to move forward with my indicator.

                  Thanks again.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by cls71, Today, 04:45 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post cls71
                  by cls71
                   
                  Started by mjairg, 07-20-2023, 11:57 PM
                  3 responses
                  213 views
                  1 like
                  Last Post PaulMohn  
                  Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                  4 responses
                  544 views
                  0 likes
                  Last Post PaulMohn  
                  Started by GLFX005, Today, 03:23 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post GLFX005
                  by GLFX005
                   
                  Started by XXtrader, Yesterday, 11:30 PM
                  2 responses
                  12 views
                  0 likes
                  Last Post XXtrader  
                  Working...
                  X