Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
One indicator change the properties of another Indicator
Collapse
X
-
One indicator change the properties of another Indicator
Is it possible for one indicator to change the properties of another indicator? Essentially I want to create Buttons on the chart that enable me to toggle on and off another indicators visible property.Tags: None
-
Hello cutzpr,
This should be possible to do.
You will need to grab the chart and list the indicators and then find a property to set using undocumented code.
An example of this is attached.
This example uses undocumented code and is not officially supported by NinjaTrader Support.Attached FilesLast edited by NinjaTrader_ChelseaB; 05-11-2021, 11:21 AM.Chelsea B.NinjaTrader Customer Service
-
Originally posted by cutzpr View PostIs it possible for one indicator to change the properties of another indicator? Essentially I want to create Buttons on the chart that enable me to toggle on and off another indicators visible property.
I have made an Addon from Jesse's original Addon to set IsVisible true/false.
Some superfluous code have not been removed and is provided 'as-is'.
I have actually learned a lot from this particular example, so thanks for posting.
I have a question for the NT team: Is it possible to add a code snippet to refresh the chart when the 'IsVisible' button is clicked.
I tried:
Code:selectedIndicator.OwnerChartControl.InvalidateVisual();
Chelsea, is it actually possible to have access to more code examples, especially interaction between xaml and C#?
Any code examples like this are priceless.
Thank you.
Comment
-
Hello Sim22,
Our code examples are written as we get inquiries and need an example to demonstrate.
NinjaTrader 8 Beta is fairly new and at this time there are not many samples written by support. However the samples written are posted publicly to the forum and I would recommend searching the forum for posts along the interested topic.
It is possible to trigger a chart to invalidate from an addon using the chart control.
Code:foreach (Window window in Globals.AllWindows) { NTWindow w = (NTWindow)window; window.Dispatcher.BeginInvoke(new Action(() => { if (!w.Caption.Contains("Chart")) return; TabControl tc = w.FindFirst("ChartWindowTabControl") as TabControl; if (tc == null) return; foreach (TabItem ti in tc.Items) { ChartControl tabChartControl = (ti.Content as ChartTab).ChartControl; if (ti.IsSelected) tabChartControl.InvalidateVisual(); } })); }
Chelsea B.NinjaTrader Customer Service
Comment
-
Thank you Chelsea
I understand, however often forum members do not tag threads properly which makes searching very time consuming.
I know your resources are strapped for time esp. since, as you say, NT8 is still fairly new. I just thought a general depository would be good where useful code could be dumped for reuse. I think it would save you guys/gals time in the long run from answering fragmented questions and save us hours from attempting to piece those fragmented snippets together
Thanks for your help all the same!
Simon.
Comment
-
To All,
Just an update to this thread.
The example in Post #2 is using undocumented code and not officially supported by NinjaTrader.
Further, we advise not invalidating the chart and instead calling ForceRefresh() to prevent deadlocks.
From the help guide:
"Warning: Excessive calls to ForceRefresh() and OnRender() can carry an impact on general application performance. You should only call ForceRefresh() if the chart truly needs to be visually updated. It is NOT recommended to invalidate the chart control directly as this could cause issues with threading which result in dead locks."
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by r68cervera, Today, 05:29 AM
|
0 responses
3 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
4 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
35 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
12 responses
3,239 views
0 likes
|
Last Post
by Leafcutter
Today, 05:08 AM
|
||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
0 responses
6 views
0 likes
|
Last Post
by AveryFlynn
Today, 04:57 AM
|
Comment