Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I have several chart indicators that add buttons and other controls to the chart ToolStrip.
The problem is that sometimes Ninja loads the indicators in an order that is different than the Indicator list where I attach the indicators to the chart.
This causes a problem because then my toolstrip controls are in a different order than I expect, which is a distraction.
If I reload the indicators (F5) the toolstrip controls are usually placed in the correct order.
Any ideas on how to fix this? I asked NinjaTrader forum some time ago and they didn't have an answer....just " that is the way it works"....no control over the order a chart loads the indicators.
Any ideas guys?
Can you help answer these questions from other members on NexusFi?
The phenomenon that you describe regularly results from
a) missing or
b) logically incorrect
z-orders of drawing objects.
Even more than proprietary order handling, z-order certainly is for advanced programers. Most beginners
are not aware of the underlying DrawObjects collection at all or don't understand the .NET concept and
therefore quickly lose track of their drawing objects. (See e.g. the level of confusion about this topic in NT
development forum discussions.)
Besides, it is a relative concept, not an absolute one. Relative means that an object's z-order is relative to all other objects and data series of the collection. Objects from a NinjaScript indicator or strategy
will generally share the same z-order as the script. Changes to that order must be done programmatically.
A classical rookie mistake (if you didn't lock your DrawObjects collection for new entries) is e.g. adding a new
object (at worst by hand during the runtime of the script) without programmatically checking - and readjusting if
necessary - the z-order of all your other objects.
If you really want to do the gruntwork and sort this out for your case, I'd recommend to start with the .NET
documentation on z-order.
" A classical rookie mistake (if you didn't lock your DrawObjects collection for new entries) is e.g. adding a new
object (at worst by hand during the runtime of the script) without programmatically checking - and readjusting if
necessary - the z-order of all your other objects."
The toolstrip controls are created during OnStartup.
The only objects created by hand are Ninja drawobjects.
Do you know of any code samples (in Futures IO) that show how to check and readjust the z-order of all other objects, as you mention?
The z-order is FOR the indicator. This can cause additional problems if an indicator produces several
objects for the collection. If you want to be absolutely sure about the z-order for any of these outputs,
you will need to decompose the indicator into single output objects.
The problem with the support of this feature for NT is that the order in which objects of your DrawObjects collection
are invoked are completely irrelevant for "the rest of the world". So NT only implements the method (publicly since
about 2009, I think - because they also need it for constructing the charts), but to the best of my knowledge, NT
neither documents this method nor gives significant examples.
Thus you will presumably find the best examples in the .NET documentation.
I just remembered, and verified this.....the above discussion might be so....but in the indicator list for the chart, the ORDER of the indicators is changing from what I entered.
And, then the toolbar matches the new order the next time the chart is loaded....so, while z-order may be important, I don't think it is causing this problem.
Something in Ninja is changing the order of the indicators in the list (Control I), perhaps when I shut Ninja down and it saves the Workspace (?), and then when the chart loads again, the order the indicators are loaded match the NEW list, which is not what I entered.
Any ideas?
When I asked Ninja before I didn't get any solution. Just "that is the way it works".