• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnRender

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

    #16
    Originally posted by NinjaTrader_Dave View Post
    At the present time, it would not be possible to draw these complex graphics on other panels due to the clipping in place, unless you were to obtain the RenderTarget of a separate panel (I'm testing out a possible way to do that now, and I'll post back with any updates).
    I'm not sure what's considered "complex graphics", but I'm simply wanting to draw a line on the price panel.

    As you mention, "obtain the RenderTarget of a separate panel" sounds like the ultimate goal. I could understand not wanting indicators to interfere with other indicators, but accessing the "Price Panel" RenderTarget seems reasonable, in my opinion.

    Thanks for looking into this for us!
    Last edited by neoikon; 11-06-2015, 09:44 AM.

    Comment


      #17
      Originally posted by NinjaTrader_Dave View Post
      Hello,

      If you are referring to using SharpDX drawing methods on RenderTarget, those objects will not have a concept of different panels, but will rather draw based upon pixel coordinates of the entire chart canvas.

      That being said, we currently have clipping logic in place that prevents SharpDX methods from drawing outside of the panel on which the indicator resides. At the present time, it would not be possible to draw these complex graphics on other panels due to the clipping in place, unless you were to obtain the RenderTarget of a separate panel (I'm testing out a possible way to do that now, and I'll post back with any updates).

      Can you explain a bit more about your goal for using Reflection with WPF? Most or all WPF classes should be fully documented.
      The clipping effect is extremely helpful. Without it I think we will have to manually handle a lot of things when custom drawing something.

      Please keep me posted about your testing of "RenderTarget of a separate panel".

      In NT7 I use Reflection to call some "hidden" methods of Chart Trader, for my order-execution indicators. Of course there are other approaches but I prefer that What about Reflection in WPF?

      Thanks.
      Last edited by ninZa; 11-11-2015, 06:34 PM.
      ninZa
      NinjaTrader Ecosystem Vendor - Ninza

      Comment


        #18
        It appears that Relfection will work with WPF assemblies. I found an interesting discussion on this at the link below:

        http://stackoverflow.com/questions/5...eflection-in-c

        There is not a direct way to obtain the Render Target of a separate chart panel, although using Reflection you may be able to obtain a reference to other charts as a starting point.
        Dave I.NinjaTrader Product Management

        Comment


          #19
          Originally posted by NinjaTrader_Dave View Post
          It appears that Relfection will work with WPF assemblies. I found an interesting discussion on this at the link below:

          http://stackoverflow.com/questions/5...eflection-in-c

          There is not a direct way to obtain the Render Target of a separate chart panel, although using Reflection you may be able to obtain a reference to other charts as a starting point.
          Yesterday I discovered how to get the ChartPanel of the price panel, now you suggest using Reflection to obtain RenderTarget of that panel. Ok we have a connection here, it seems to be a progress

          Thanks, Dave.
          ninZa
          NinjaTrader Ecosystem Vendor - Ninza

          Comment


            #20
            By Reflection you can get all references to others RenderTarget you want.
            The issue is you cannot use those references outside the indicator to which they belong. Is it not ?

            Comment


              #21
              I dig out this thread because I'm facing the same problem.

              Since the last message, did you find a way to draw a simple line on price panel from an indicator in the indicator panel using SharpDX method ?

              Thanks.

              Comment


                #22
                No, I did not get it.
                When I use the RenderTarget of another indicator panel I always get exceptions.

                Comment


                  #23
                  I still haven't discovered a solution to this. However, just to verify I'm trying to accomplish the same thing as others are discussing...

                  I have a chart with multiple Panels (by adding additional instruments in the Data Series dialog box (^TICK, for example)).

                  I added a custom indicator to the chart and I set one of these additional data series as the Input. I also set the indicator to use the Panel "same as input series".

                  In the indicator, I make a call like something like this to output a shaded area:

                  PHP Code:
                  RenderTarget.FillGeometry(pathGeometrylinebrush); 
                  There isn't an error, but nothing is outputted. If I change the input series to the first item and use Panel "0", then it works as expected (but on the wrong Panel/Data Series, obviously).

                  I've tried setting DrawOnPricePanel to false and to true, but it doesn't seem to make a difference.

                  I'm assuming that the "RenderTarget" is the one from the first Panel and not from the Panel my indicator is running, correct? Is there a way to get the RenderTarget that I want?

                  Any help is greatly appreciated!
                  Last edited by neoikon; 07-18-2016, 04:07 PM.

                  Comment


                    #24
                    Hello neoikon,

                    I would expect the output to render on the same panel that the indicator is on.

                    Can you provide an example script demonstrating the behavior you're seeing so I may test on my end?
                    Zachary G.NinjaTrader Customer Service

                    Comment


                      #25
                      Here is a quick and dirty indicator to demonstrate what I'm seeing (named "Example Shade BG")

                      PHP Code:
                      using System.Windows.Media;
                      using NinjaTrader.Gui;
                      using NinjaTrader.Gui.Chart;

                      namespace 
                      NinjaTrader.NinjaScript.Indicators
                      {
                          public class 
                      ExampleShadeBG Indicator
                          
                      {
                              protected 
                      override void OnStateChange()
                              {
                                  if (
                      State == State.SetDefaults)
                                  {
                                      
                      Name "Example Shade BG";
                                      
                      IsOverlay true//false;
                                      
                      DrawOnPricePanel false
                                  }
                              }

                              protected 
                      override void OnRender(ChartControl chartControlChartScale chartScale)
                              {
                                  
                      base.OnRender(chartControlchartScale);
                                  
                      FillRectangleFromDimensions(00, (float)chartScale.Width, (float)chartScale.HeightBrushes.Lime0.2f);
                              }

                              private 
                      void FillRectangleFromDimensions(float Xfloat Yfloat RecWidthfloat RecHeightBrush bgBrushfloat bgOpacity)
                              {
                                  
                      SharpDX.RectangleF rect = new SharpDX.RectangleF(XYRecWidthRecHeight);
                                  
                      Brush tempBrush bgBrush.Clone();
                                  
                      tempBrush.Opacity bgOpacity;
                                  if (!
                      IsInHitTest && tempBrush != null)
                                      
                      RenderTarget.FillRectangle(recttempBrush.ToDxBrush(RenderTarget));
                              }
                          }

                      Steps to reproduce:
                      1. Open New chart and add this indicator. It will shade the entire background green
                      2. Go to to the "Data Series" dialog and add a new input series (such as ^ADD)
                      3. Change the input to the indicator to be this new Input Series, verify the "Panel" is set to display "Same as Input Series"
                      4. I would expect the new Input Series Panel to then be shaded green, but instead, nothing is outputted. Putting some "Print" statements show that the function is called and the values are as expected.


                      I've tried changing DrawOnPricePanel and IsOverlay to different settings without luck.

                      Is there another flag that I need to change? Something I need to do to RenderTarget? Something else?

                      Thanks!

                      Comment


                        #26
                        Hello neoikon,

                        Thank you for providing that example.

                        I see on this line of code:
                        Code:
                        FillRectangleFromDimensions(0, 0, (float)chartScale.Width, (float)chartScale.Height, Brushes.Lime, 0.2f);
                        That you are specifying an X value of 0 and Y value of 0. This would just be the top left corner of the chart canvas itself.

                        Try this instead:
                        Code:
                        FillRectangleFromDimensions(ChartPanel.X, ChartPanel.Y, (float)chartScale.Width, (float)chartScale.Height, Brushes.Lime, 0.2f);
                        Zachary G.NinjaTrader Customer Service

                        Comment


                          #27
                          Thank you for the reply. Did that fix the issue for you? Unfortunately, I am getting the same behavior on my end with the recommended changes.

                          The goal of that example was simply to shade an area of the chart (in this case, the entire chart, starting from the top left corner (0,0) and the whole height/width of the chart).

                          My actual script is a few thousand lines long, but this simple example is experiencing the same behavior I am with mine. If I can get this simple script to work, then I will apply that solution to mine.
                          Last edited by neoikon; 07-21-2016, 11:44 AM.

                          Comment


                            #28
                            Hello neoikon,

                            With the small change I have implemented, the behavior that you have specified no longer occurs.
                            1. When adding your original sample indicator to a chart, it shades the entire chart green, as expected (attached picture Shade1).
                            2. When adding a secondary series to your chart and applying the indicator to that panel, the indicator does not shade the panel (attached picture Shade2).
                            3. Upon implementing the change I have mentioned in my previous post, the panel now shades green as expected (attached picture Shade3).


                            As a test, please download the attached modified indicator and see if you are still seeing this behavior.
                            Attached Files
                            Zachary G.NinjaTrader Customer Service

                            Comment


                              #29
                              Originally posted by NinjaTrader_ZacharyG View Post
                              Hello neoikon,

                              With the small change I have implemented, the behavior that you have specified no longer occurs.
                              1. When adding your original sample indicator to a chart, it shades the entire chart green, as expected (attached picture Shade1).
                              2. When adding a secondary series to your chart and applying the indicator to that panel, the indicator does not shade the panel (attached picture Shade2).
                              3. Upon implementing the change I have mentioned in my previous post, the panel now shades green as expected (attached picture Shade3).


                              As a test, please download the attached modified indicator and see if you are still seeing this behavior.
                              Can you suggest a solution to paint both panel 1 & panel 2 (entire chart canvas)?

                              Thanks.
                              ninZa
                              NinjaTrader Ecosystem Vendor - Ninza

                              Comment


                                #30
                                Hello ninZa,

                                Unfortunately, you would be unable to render items outside of the panel the script resides on.

                                Custom drawing on charts is done using SharpDX drawing methods in NinjaTrader 8, which rely on pixel coordinates of an entire chart to place drawn objects. However, there is custom clipping logic in place to ensure that a SharpDX draw object cannot be located outside the bounds of the panel on which the associated script resides.

                                One way to get around this that I can think of is to have a strategy call an indicator (that will reside in a different panel) with AddChartIndicator() and to have both scripts have their own OnRender() methods.
                                Attached Files
                                Zachary G.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by jjnc2006, Today, 07:36 PM
                                0 responses
                                3 views
                                0 likes
                                Last Post jjnc2006  
                                Started by futurenick, Today, 06:26 AM
                                1 response
                                11 views
                                0 likes
                                Last Post nkhoi
                                by nkhoi
                                 
                                Started by NinjaCustomer, Today, 12:29 PM
                                1 response
                                9 views
                                0 likes
                                Last Post NinjaTrader_ShawnB  
                                Started by Steve L, Today, 11:32 AM
                                0 responses
                                7 views
                                0 likes
                                Last Post Steve L
                                by Steve L
                                 
                                Started by prabbala, Today, 10:41 AM
                                0 responses
                                4 views
                                0 likes
                                Last Post prabbala  
                                Working...
                                X