This works fine if you change the properties of the indicator via the Indicators window, and the properties shows the flag correctly.
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!
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
NinjaTrader
Changing IsVisible on Indicator in code doesn't hide draw objects.
Collapse
X
-
Changing IsVisible on Indicator in code doesn't hide draw objects.
I have code that toggles the visibility of an indicator using Indicator.IsVisible. This will successfully hide/show the plot lines of an indicator such as SMA, but will not hide any draw objects created by an indicator such as the Candle Stick Pattern Indicator.
This works fine if you change the properties of the indicator via the Indicators window, and the properties shows the flag correctly.Tags: None
-
According to this link https://ninjatrader.com/support/help...?isvisible.htm it is documented and Indicators are NinjaScript objects.
Further investigation reveals that changing the visible property of the indicator in the properties dialog causes all the existing drawing objects to be deleted. Making it visible again causes them to be recreated. I am making an educated guess this has to do with the fact that opening hitting ok or apply in the properties window causes the existing indicator object to be destroyed, taking all the drawing objects it owns with it, and a new one to be created that doesn't create any drawing objects due to not being visible.
As a work around for any looking for a way to make this work, one can iterate through all the DrawingTool objects in ChartObjects property of the Indicator, and toggle the IsVisible flag on the drawing objects if they are owned by the indicator. This works, though is likely considered an unsupported means of doing this.
Comment
-
Hello ntbone,
My mistake. I was looking at an internal document that stated IsVisible is intentionally not documented.
Thank you for providing the link to the documentation on this (that shows my internal information is out of date).
I gave this a test. I'm finding if IsVisible is set in State.DataLoaded or in a state previous, this works as expected. If set after a drawing object is drawn, the object is not removed.
Are you able to set IsVisible in State.DataLoaded?
I am inquiring further if this is supported to set to false in realtime.Chelsea B.NinjaTrader Customer Service
Comment
-
Unfortunately no. I have an addon that adds functionality to hide all indicators. It loops through all the indicators for a chart and turns the visibility on or off. The side effects of this include- Drawing objects created by any indicator not disappearing.
- Panels created by indicators like the moving average disappear but the space they occupied is not adjusted.
Comment
-
Hello ntbone,
Our development confirmed, this setting simply prevents the script from processing. So rendered objects like plots or custom renders are not rendered because OnRender is never called. However, this does not cause existing drawing tool objects to be removed from the chart or any other actions to occur.
Possibly RemoveAllDrawObjects() could cause these to be removed before setting the IsVisible.
With custom panels not removed, I will create a report for this. Once I have a tracking ID for this report I will post in this thread.Chelsea B.NinjaTrader Customer Service
Comment
-
I tried RemoveAllObjects but then when you toggle to make them visible again, they are not regenerated and thus never re-appear. CandleStick indicator is a good example. Sounds like my solution of hiding/showing the attached drawing objects is the best way to go to get what I want.
Comment
-
Hello ntbone,
I've received tracking ID# SFT-4011 for this request to remove a panel if the only indicator on it has IsVisible set to false and tracking ID# SFT-4021 for the request for removing and re-adding drawing objects automatically if IsVisible is set to false/true.
Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.
We appreciate your feedback.Last edited by NinjaTrader_ChelseaB; 05-28-2019, 03:25 PM.Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello ntbone,
I've received tracking ID# SFT-4011 for this request to remove a panel if the only indicator on it has IsVisible set to false and tracking ID# SFT-4021 for the request for removing and re-adding drawing objects automatically if IsVisible is set to false/true.
Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.
We appreciate your feedback.
Hello,
please add my vote forID# SFT-4011 and ID# SFT-4021 feature requests.
Thank you.
Comment
-
-
Originally posted by ntbone View PostI have code that toggles the visibility of an indicator using Indicator.IsVisible. This will successfully hide/show the plot lines of an indicator such as SMA, but will not hide any draw objects created by an indicator such as the Candle Stick Pattern Indicator.
This works fine if you change the properties of the indicator via the Indicators window, and the properties shows the flag correctly.
Comment
-
The code to hide the drawing objects is very straight forward and won't fix your problem unless you are using the drawing objects. If you are calling AddPlot to render your visuals then the code that I have won't help you.
Code:private void ShowIndicator(bool isVisible) { foreach(var chartObject in chartWindow.ActiveChartControl.ChartObjects) { var indicator = chartObject as Indicator; if(indicator != null && indicator.DrawOnPricePanel) { indicator.IsVisible = isVisible; ToggleIndicatorDrawingObjectVisibilty(indicator, isVisible); } } // forces the chart to redraw. chartWindow.ActiveChartControl.InvalidateVisual(); } private void ToggleIndicatorDrawingObjectVisibilty(Indicator indicator, bool isVisible) { foreach(var obj in indicator.DrawObjects) { if(obj.DrawnBy == indicator) { obj.IsVisible = isVisible; } } }
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by aussugardefender, Today, 01:07 AM
|
0 responses
3 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
238 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
384 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
||
Started by oviejo, Today, 12:28 AM
|
0 responses
4 views
0 likes
|
Last Post
by oviejo
Today, 12:28 AM
|
||
Started by pechtri, 06-22-2023, 02:31 AM
|
10 responses
125 views
0 likes
|
Last Post Today, 12:03 AM |
Comment