Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

drawing on multiple panels from within an indicator

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

    drawing on multiple panels from within an indicator

    I wondered what the best way if possible to draw on the main price panel 1 from a loaded indicator. So i have an indicator in a lower panel which mostly draws on that panel i would like to include instances within the indicator code to additionally draw on the panel 1 ie change candle / bar colours. I recall there was flexibility in the drawing to be able to reference different drawing regions/panels but not clear on this.

    thanks on any input on this

    #2
    Hello,

    There are two ways to approach this question. Strictly speaking, there is not a way to place drawing objects on multiple panels at once at this time. You can use the DrawOnPricePanel property to draw on the price panel if your indicator resides on a separate panel, but that would not allow you to draw on the indicator panel at the same time.

    That being said, it sounds like you are actually looking for a way to change properties of bars in a separate panel, and that can be done. The key is to check through the ChartObjects in the appropriate index of the ChartControl.ChartPanels collection, then change the ChartStyle properties within that ChartPanel, like so:

    Code:
                foreach(Gui.NinjaScript.IChartObject obj in ChartControl.ChartPanels[0].ChartObjects)
                {
                    if(obj.Name.ToString() == "ChartBars")
                    {
                        ChartBars cb = obj as ChartBars;
                        cb.Properties.ChartStyle.Stroke.Brush = Brushes.Blue;
                    }
                }
    You can find more information about changing bar properties at the link below:

    Dave I.NinjaTrader Product Management

    Comment


      #3
      Hello, thank for the reply. How i managed this in NT7 was to have 2 versions of an indicator - one which draws in the indicator panel and another which utilises similar logic but the drawing is applied to the main panel. I was hoping there was a way to circumvent loading essentially 2 albeit slightly different instances of an indicator.
      In your example above this would change the color/brush / wick whichever aspect of the bars for the entire bar range - is it possible to isolate the Current bar / using Current bar or a time range (which i would include in the logic) or index via the if ( idx != LastBarIndexPainted ) - as illustrated in the link you sent. ie so that only certain bars properties would change given a qualifying test.
      thanks

      Comment


        #4
        I wonder also if this could be forwarded as a feature request and given the the more open Drawing Package and Window layout management i would imagine this would be feasible at some point in future releases?
        thanks

        Comment


          #5
          I've create a new feature request to track demand for this change. I've heard this request more than once throughout the Beta period, as well. It can be tracked with ID # SFT-962.

          I will post back soon with info on changing individual bar properties.
          Dave I.NinjaTrader Product Management

          Comment


            #6
            Originally posted by NinjaTrader_Dave View Post
            I will post back soon with info on changing individual bar properties.
            The BarBrushes collection will allow you to set the Brush for individual historical bars in the Bars series. However, there do not appear to be related collections for other bars properties. For the greatest flexibility in dynamically changing bars properties, your best bet would be to approach the goal with a custom Chart Style and/or Bar Type.
            Dave I.NinjaTrader Product Management

            Comment


              #7
              Hello, i wondered if it is my best bet in the interim to create custom chart style / bar type or if this is to be how this is handled going forward - ie no way to reference panel id where drawing/rendering to take place? I will take a look at the Brush collection for the bar colours.
              Also can you take a look at the Drawing link in the NT8 help page - to me it is misleading as in footnote 1 it implies the capability to draw on both panels is available and possible though does not give example of how to do so.
              thanks

              Comment


                #8
                Originally posted by soulfx View Post
                Hello, i wondered if it is my best bet in the interim to create custom chart style / bar type or if this is to be how this is handled going forward - ie no way to reference panel id where drawing/rendering to take place? I will take a look at the Brush collection for the bar colours.
                Also can you take a look at the Drawing link in the NT8 help page - to me it is misleading as in footnote 1 it implies the capability to draw on both panels is available and possible though does not give example of how to do so.
                thanks
                Are you using the Draw.<Object>() methods?

                Comment


                  #9
                  Am using both Draw.<object> and the OnRender methods in the OnRender override.
                  Does it make a difference if one set is used and the OnRender is not depending on the Windows OS version?

                  Comment


                    #10
                    Originally posted by soulfx View Post
                    Am using both Draw.<object> and the OnRender methods in the OnRender override.
                    Does it make a difference if one set is used and the OnRender is not depending on the Windows OS version?
                    If you are using Draw.<object>() methods, then you can use the DrawOnPricePanel property to specify the drawing location: PricePanel or IndicatorPanel. Yes, it can still be done dynamically, and I believe that unlike NT7, where it was possible, but unsupported, in NT8, I think that it is a supported scenario.

                    ref: http://ninjatrader.com/support/forum...31428#poststop
                    Last edited by koganam; 12-10-2015, 03:07 PM. Reason: Corrected spelling.

                    Comment


                      #11
                      Thank for note, interesting they have not indicated this when i asked the question and would be good if Ninja could confirm if this is/will be supported or remain unsupported in NT8. Good trick to be aware of and will try out in NT7.
                      The other question i posted was related to the DirectX in another thread as to how this would be supported for Windows OS pre version 8 as directX SDK is available in windows 8 onwards and how this would be handled for windows 7 etc installations.

                      thanks for tip

                      Comment


                        #12
                        Originally posted by soulfx View Post
                        ...
                        The other question i posted was related to the DirectX in another thread as to how this would be supported for Windows OS pre version 8 as directX SDK is available in windows 8 onwards and how this would be handled for windows 7 etc installations.

                        thanks for tip
                        NT8 is using SharpDX for rendering. No need for any fancy footwork, as SharpDX works all the way back to Windows XP.

                        ref: http://sharpdx.org/about/features

                        Comment


                          #13
                          Yes, the technique of dynamically setting DrawOnPricePanel will still be valid in NinjaTrader 8. Keep in mind again that this applies to NinjaScript Drawing Tools, not to SharpDX drawing methods (those called on RenderTarget). Also, keep in mind that this allows you to dynamically draw on either the price panel or the indicator panel, which means it will not, for example, allow you to draw a single object spanning multiple panels, or allow drawing in any panel other than those specific two.

                          You should be fine to run on Windows 7, as it falls into the minimum system requirements listed at the link below:

                          http://ninjatrader.com/support/helpG...n-us/?beta.htm

                          That being said, please let us know if you start running into DirectX errors, so that we can investigate further.
                          Dave I.NinjaTrader Product Management

                          Comment


                            #14
                            Originally posted by soulfx View Post
                            the Drawing link ... does not give example of how to do so.
                            Good catch. You can find an example here, and I've added a link in the Drawing page which leads to that page, to make it easier to follow.
                            Dave I.NinjaTrader Product Management

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by mgco4you, Today, 09:46 PM
                            1 response
                            2 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by wzgy0920, Today, 09:53 PM
                            0 responses
                            3 views
                            0 likes
                            Last Post wzgy0920  
                            Started by Rapine Heihei, Today, 08:19 PM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by Rapine Heihei, Today, 08:25 PM
                            0 responses
                            6 views
                            0 likes
                            Last Post Rapine Heihei  
                            Started by f.saeidi, Today, 08:01 PM
                            1 response
                            9 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Working...
                            X