Currently the solution I can think of is creating a static Dictionary which holds the values for the drawing tools, organized by an unique identifier. Even though I expect it to work, it seems really overcomplicated, as this syncing is already done by NinjaTrader, if you're configuring the drawing tool through the interface. I suspect there is some function prepared to do this syncing already.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Syncing variables of global drawing tools
Collapse
X
-
Syncing variables of global drawing tools
Hi, I'm developing an Indicator which updates a boolean variable in a custom Drawing Tool. The problem is: the drawing tool is attached to a symbol in all time-frames(global), and the variable I've set is only changing in the time-frame where the Indicator is running, and I need it to update on all time frames.
Currently the solution I can think of is creating a static Dictionary which holds the values for the drawing tools, organized by an unique identifier. Even though I expect it to work, it seems really overcomplicated, as this syncing is already done by NinjaTrader, if you're configuring the drawing tool through the interface. I suspect there is some function prepared to do this syncing already. -
Hello Matheusfx,
Unfortunately, Global Drawing Objects are copies of the original object and not the same instance of the original drawing object added to the chart.
Because of this any properties are also independent for each instance that's appearing on the other charts,
There is an existing feature request (SFT-2479) we are tracking to increase custom drawing tool context menu abilities and I will be adding your vote toward this.
Using static methods getting out of what is supported by NinjaTrader Support, but may be possible.
This thread will remain open for any community members that would like to assist.
Another possible solution is to create an Add On that loops through the charts and adds the Context Menu items that way in order to have the items consistently update between the instances.Chelsea B.NinjaTrader Customer Service
-
is there any update to SFT-2479 ability to increase custom drawing tool context menu abilities.
generally this is working fine when i add and remove items from the custom drawing tool context menu during open and close
however when i open the indicator window and make a change and select apply ok
it seems to have an effect on the add remove functions for the context menu and i end up with duplicates
i am checking through the state lifecycle for this ie terminate - historical - terminate etc to see where the issue could lie
i presume there are limitations of drawing tool context menu modifications? this is still unsupported code?
any guidelines on this would be appreciated.
As i said all works well until f5 or open indicator window then APPLY and OK - then the items in the drawing tool context menu when right clicking seem to get duplicate
and the close context menu function doesnt always get invoked. in the close i remove all the custom menu items since on the open it varies which ones should appear based on some logic i have in place.
thanks
Comment
-
Hello explorer101,
Feature request SFT-2479 has not been implemented at this time.
Please note it is up to the NinjaTrader Development to decide if or when any request will be implemented.
To confirm, your inquiry is related to this thread?
Are you attempting to make changes to the properties of global drawing objects on multiple charts?
You have mentioned that something is being duplicated in the drawing tool context menu? Is this a NinjaTrader menu item that is being duplicated?
Where you have mentioned "i presume there are limitations of drawing tool context menu modifications? this is still unsupported code? "
Adding items to a drawing tool's context menu would not be documented but may be possible using undocumented code. Attached is an example.
Attached FilesChelsea B.NinjaTrader Customer Service
Comment
-
thanks for sharing the example - i did look at this a while back so not sure if has been updated at all?
I will review my use of this - i was using and setting the drawing tool items slightly differently as i manage the custom drawing objects in a slightly different manner
I will rework if necessary to this structure i just need to review
will update
thanks
Comment
-
meant to say can you also add my vote to SFT-2479 - im not sure i voted in past but you can check
Comment
-
-
For anybody coming across this thread in the future, I was able to solve this by using reflection.
After messing around for a long time with intellisense and decompilation, I found that NinjaTrader has a static class that manages Global Drawing Tools, called GlobalDrawingToolManager. It has a private method called OnChange, that can be used to update the other instances of your global drawing tool after you modify the desired attribute.
Here's the code showing how to use it:
Code:[COLOR=#789deb]const [/COLOR][COLOR=#e1bfff]BindingFlags [/COLOR][COLOR=#66b9cc][B]bindingFlags [/B][/COLOR][COLOR=#bdbdbd]= [/COLOR][COLOR=#e1bfff]BindingFlags[/COLOR][COLOR=#bdbdbd].[/COLOR][COLOR=#66b9cc][B]NonPublic [/B][/COLOR][COLOR=#bdbdbd]| [/COLOR][COLOR=#e1bfff]BindingFlags[/COLOR][COLOR=#bdbdbd].[/COLOR][COLOR=#66b9cc][B]Static [/B][/COLOR][COLOR=#bdbdbd]| [/COLOR][COLOR=#e1bfff]BindingFlags[/COLOR][COLOR=#bdbdbd].[/COLOR][COLOR=#66b9cc][B]IgnoreCase [/B][/COLOR][COLOR=#bdbdbd]| [/COLOR][COLOR=#e1bfff]BindingFlags[/COLOR][COLOR=#bdbdbd].[/COLOR][COLOR=#66b9cc][B]IgnoreReturn [/B][/COLOR][COLOR=#bdbdbd]| [/COLOR][COLOR=#e1bfff]BindingFlags[/COLOR][COLOR=#bdbdbd].[/COLOR][COLOR=#66b9cc][B]Public [/B][/COLOR][COLOR=#bdbdbd]| [/COLOR][COLOR=#e1bfff]BindingFlags[/COLOR][COLOR=#bdbdbd].[/COLOR][COLOR=#66b9cc][B]InvokeMethod[/B][/COLOR][COLOR=#bdbdbd];[/COLOR] var onChanged [COLOR=#bdbdbd]= [/COLOR][COLOR=#789deb]typeof[/COLOR][COLOR=#bdbdbd]([/COLOR]GlobalDrawingToolManager[COLOR=#bdbdbd]).[/COLOR]GetMethod[COLOR=#bdbdbd]([/COLOR][COLOR=#dea860]"OnChanged"[/COLOR][COLOR=#bdbdbd], [/COLOR]bindingFlags[COLOR=#bdbdbd]);[/COLOR] [COLOR=#789deb]var [/COLOR][COLOR=#bdbdbd]parametersArray = [/COLOR][COLOR=#789deb]new object[/COLOR][COLOR=#bdbdbd][] { chartControl, drawingTool };[/COLOR] [COLOR=#66b9cc]onChanged[/COLOR][COLOR=#bdbdbd].[/COLOR][COLOR=#39cca1]Invoke[/COLOR][COLOR=#bdbdbd]([/COLOR][COLOR=#789deb]null[/COLOR][COLOR=#bdbdbd], parametersArray);[/COLOR]
This seems to be the way it's done by NinjaTrader when updating the drawing tool through the UI. Unless there's a better way to do this, it should become a public method, to remove the need for using reflection, and should also be documented.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by PaulMohn, Today, 12:36 PM
|
2 responses
16 views
0 likes
|
Last Post
by PaulMohn
Today, 01:48 PM
|
||
Started by Conceptzx, 10-11-2022, 06:38 AM
|
2 responses
53 views
0 likes
|
Last Post
by PhillT
Today, 01:47 PM
|
||
Started by Kaledus, Today, 01:29 PM
|
0 responses
4 views
0 likes
|
Last Post
by Kaledus
Today, 01:29 PM
|
||
Started by yertle, Yesterday, 08:38 AM
|
8 responses
37 views
0 likes
|
Last Post
by ryjoga
Today, 01:22 PM
|
||
Started by rdtdale, Today, 01:02 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:13 PM |
Comment