[COLOR=#0000ff]protected[/COLOR] [COLOR=#0000ff]override[/COLOR] [COLOR=#0000ff]void[/COLOR] [COLOR=#080808]OnRender[/COLOR]([COLOR=#080808]ChartControl[/COLOR] [COLOR=#080808]chartControl[/COLOR], [COLOR=#080808]ChartScale[/COLOR] [COLOR=#080808]chartScale[/COLOR]) { [COLOR=#0000ff]if[/COLOR] (![COLOR=#080808]IsVisible[/COLOR] || [COLOR=#080808]Bars[/COLOR] == [COLOR=#0000ff]null[/COLOR] || [COLOR=#080808]ChartControl[/COLOR] == [COLOR=#0000ff]null[/COLOR]) [COLOR=#0000ff]return[/COLOR]; [COLOR=#0000ff]base[/COLOR].[COLOR=#080808]OnRender[/COLOR]([COLOR=#080808]chartControl[/COLOR], [COLOR=#080808]chartScale[/COLOR]); }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
OnRender
Collapse
X
-
OnRender
Adding an OnRender override seems to be effecting plot zordering.. Add this to any indy with a plot..
Code:
Tags: None
-
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
-
Originally posted by NinjaTrader_Matthew View PostHmm, 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 } }
Comment
-
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. }
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
-
Originally posted by NinjaTrader_Matthew View PostSo 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. }
Comment
-
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
-
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);
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
-
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:
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
-
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
-
Originally posted by NinjaTrader_Matthew View PostI've reported the issue of the "corrupt" ZOrder in NTEIGHT-10072. Thanks for bringing that to our attention.
Comment
-
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
-
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 PostI 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 Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
71 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
4 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
9 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
13 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
Comment