• 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

    OnRender

    Adding an OnRender override seems to be effecting plot zordering.. Add this to any indy with a plot..

    Code:
     protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
     {
          if (!IsVisible || Bars == null || ChartControl == null) return;
          base.OnRender(chartControl, chartScale);
     }
    Once the chart is loaded, set the Bar zorder to be 1 or on top of everything.. Refresh the chart and the plots are always back on top.. Major Pain..

    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    #2
    Hmm, I'm not able to reproduce using a very basic script-> the ZOrder is persisted after I refresh the charts. Do you mean reloading historical data, or just reload NinjaScript?

    At any rate, there is a new SetZOrder() method for indicators which should help here

    Code:
    protected override void OnStateChange()
    {
    	if (State == State.Historical)
    	{
    		this.SetZOrder(-1);  // set the plots to one index level behind the bars
    	}
    }
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Matthew View Post
      Hmm, I'm not able to reproduce using a very basic script-> the ZOrder is persisted after I refresh the charts. Do you mean reloading historical data, or just reload NinjaScript?

      At any rate, there is a new SetZOrder() method for indicators which should help here

      Code:
      protected override void OnStateChange()
      {
          if (State == State.Historical)
          {
              this.SetZOrder(-1);  // set the plots to one index level behind the bars
          }
      }
      hmmm funny in that I can not consistently reproduce this now either.. But your setzorder suggestion does seem to work, although not until manually setting them after the first time the indys are applied.. If I open a new chart.. apply 3 indys to it, each using the OnRender, each having the setzorder set to -1 in State.Historical.. The first time you click ok or apply, all the indy's are still on top of the bars.. Once you manually set them, they now seem to stay, but is there anyway to make sure they come up a specific way the very first time?

      -=Edge=-
      NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

      Comment


        #4
        Well, in that case you can just sign ZOrder directly if you know the index levels that you're dealing with on those indicators.

        Before controlling ZOrder programmatically or through the UI, these objects by default exists on the following ZOrder indexes:

        Chart Bars 1
        NinjaScript Objects 10001
        Global Draw Objects 20001
        Draw Objects 30001


        So if you want your indicators to be behind your bars, you can just assign

        Code:
        else if (State == State.Configure)
        {				
        	ZOrder = -100;  // Set ZOrder to any value less than 0, which will force it behind the chart bars.
        }
        If you have 3 indicators, and you want one to be on top of the other, you can just make sure the desired indicator plot you wish to be on top of the other indicators has a Higher index value.

        The SetZOrder() method is just a helper if you don't want to worry about about absolute Indexes. Using the actual ZOrder value in State.Configure should allow you more flexibility.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Originally posted by NinjaTrader_Matthew View Post
          So if you want your indicators to be behind your bars, you can just assign

          Code:
          else if (State == State.Configure)
          {                
              ZOrder = -100;  // Set ZOrder to any value less than 0, which will force it behind the chart bars.
          }
          If you have 3 indicators, and you want one to be on top of the other, you can just make sure the desired indicator plot you wish to be on top of the other indicators has a Higher index value. Using the actual ZOrder value in State.Configure should allow you more flexibility.
          Ah.. works much better in config than in setdefaults.. Thank You very much! A follow up question.. Lets say I have those same 3 indicators loaded on my chart.. each with ZOrder = -1 set in State.Config.. Will they all by default be behind the bars and their ultimate zorder to each other be determined by the order in which they were added to the chart?

          -=Edge=-
          NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

          Comment


            #6
            They'd all reside on the same ZOrder, but since you set to -1, they will be behind the chart bars. You can test this by adding the following to your code in OnBarUpdate or OnRender if you wish to test.

            Code:
            if(CurrentBar == 0)
            {
            	Print(this.ZOrder + " : " + Plots[0].Name);
            	Print(ChartBars.ZOrder);
            }
            MatthewNinjaTrader Product Management

            Comment


              #7
              NT8-B11: ZOrder with OnRender Override not working properly,

              I am having some problems with ZOrder, which does not work as expected.

              So far it is not clear, where and how ZOrder shall be used. Also there seem to be two options to set the ZOrder and to make an indicator plot behind the bars:

              Code:
              ZOrder = -100;
              SetZOrder(-100);
              I have used both options in combination with a custom plot overriding OnRender.

              When setting ZOrder in State.Active as explained in the help file, it does not work. It also does not work when used within State.SetDefaults. The only place, where it has an impact is within State.Configure. I have therefore used the code above in State.Configure.

              Results:

              When I add the indicator to the chart, it first shows as expected. The indicator is plotted behind the bars.

              However, there is a problem

              - when I subsequently change ZOrder manually via shift + mouse wheel
              - and then refresh the chart via F5

              In this case the chart is frozen in the new state and the ZOrder can no longer be accessed via shift + mouse wheel. Also the chart stays "corrupted", when the indicator is removed and then added again to that chart. The chart even stays "corrupted", when I add a different indicator with a custom plot that overrides OnRender. The corruption does not affect indicators which do not override OnRender().

              There were no error messages in the trace or log files.
              Last edited by Harry; 07-02-2016, 11:26 AM.

              Comment


                #8
                I've reported the issue of the "corrupt" ZOrder in NTEIGHT-10072. Thanks for bringing that to our attention.

                Regarding the help guide... there was an early development effort to provide a helper method for ZOrder which has since been dropped as it was not working as expected. I've removed SetZOrder() from the help guide to prevent confusion for the time being. We will see if there will be new efforts to wire up that helper method in the future, but right now it is effectively the same as using the ZOrder setter/getter, which is the current recommended approach

                I've also updated the help guide to address the confusion of the required State and given a better example:

                http://ninjatrader.com/support/helpG...art_zorder.htm

                Please let me know if you have any additional questions about this functionality and I'll be happy to pass any questions/doubts to development while this item is being looked into.
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Custom sample plot: ZOrder cannot be changed after refreshing via F5

                  I have just tested the Custom sample plot that comes with NinjaTrader.

                  It shows the same behavior as my custom indicator. When you add it to a chart, the ZOrder can be changed manually via shift button + mouse wheel. Once you refresh the chart via F5, the ZOrder can no longer be changed and the chart is "corrupted".

                  The behavior is 100% reproducible.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Matthew View Post
                    I've reported the issue of the "corrupt" ZOrder in NTEIGHT-10072. Thanks for bringing that to our attention.
                    Aren't these the same? NTEIGHT-9772 ? I haven't researched to see if this was resolved and this "happened" again in a later release. Just wondering...

                    http://ninjatrader.com/support/forum...=chart+objects

                    Comment


                      #11
                      It is probably related but not exactly the same.

                      What I discovered is that ZOrder works as expected when an indicator with a custom plot is first added to a chart, but

                      - for indicators with a custom plot (does not impact other indicators)
                      - when ZOrder has been changed manually by the user
                      - and when the chart is refreshed via F5 afterwards

                      there is a conflict between the programmatically set and the manually selected setting. As a consequence ZOrder stops working and can no longer be set manually.

                      This is a different issue compared to the issue described in the other thread.

                      Comment


                        #12
                        This issue only seems to be partly fixed. When I add the custom plot to my chart

                        -> I can put the bars behind the plot (selecting level 4 of 4)
                        -> then refresh via F5
                        -> afterwards when the bars are moved back to level 1, they will not show on top, but stay behind
                        -> however, they can be moved back to the top by selecting level 1 and then refreshing via F5

                        This behavior is strange and certainly not as intended. As before, the problem only occurs when a custom plot is used.

                        Originally posted by Harry View Post
                        I have just tested the Custom sample plot that comes with NinjaTrader.

                        It shows the same behavior as my custom indicator. When you add it to a chart, the ZOrder can be changed manually via shift button + mouse wheel. Once you refresh the chart via F5, the ZOrder can no longer be changed and the chart is "corrupted".

                        The behavior is 100% reproducible.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by aligator, Today, 10:11 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post aligator  
                        Started by psquare, Today, 03:11 PM
                        4 responses
                        18 views
                        0 likes
                        Last Post psquare
                        by psquare
                         
                        Started by ballboy11, Today, 03:20 PM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by tonynt, Today, 02:18 PM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_JoshG  
                        Started by denalek2419, Today, 01:46 PM
                        3 responses
                        12 views
                        0 likes
                        Last Post NinjaTrader_ChristopherJ  
                        Working...
                        X