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)
Okay... I just found this thread and I am trying to do the same exact thing.
I want to modify the properties for a strategy at runtime. I know that NT is using a GridControl to store the properties, such as:
[Description("Trade second contract")]
[GridCategory("Parameters")]
public bool TradeSecondContract
{
get { return useContract2; }
set { useContract2 = value; }
I did find where the base strategy has a ParameterCollection that can be accessed through this.Parameters. It contains each of my parameters as their types... but not the description and grid category.
I have tried modifying this list and it does not affect the GridControl.
I'm sure there must be some way to get a reference to the GridControl, but I have yet to find it.
I need to explore under the this.ChartControl.Controls... but I don't think that will be where it is.
This evening I plan on installing a tool to decompile the Ninjatrader dll's and look around. If you ever found an answer to your question please let me know.
Can you help answer these questions from other members on NexusFi?
Hi,
No I didn't find an answer.
I attached an example how to do it in c# (properties are standart c# method)
If you will be able to do it I would appreciate if you share.
Please see the attached file for an example on how this is done. Basically indicator must implement the ICustomTypeDescriptor interface, and each properties that affects other properties must have :
When the property grid queries the indicator, it looks for an implementation of ICustomTypeDescriptor. If it's there, the GetProperties method is called instead of using reflection for the properties. A copy is made because the PropertyDescriptorCollection is readonly (so it won't work if you alter that method in this example).
I've made it relatively easy to display the properties you want - just change rewrite the ModifyProperties method. You can see two example properties that hide each other in this case.
I only regret that futures.io (formerly BMT) only let's me thank you once for that post!!
I created a forum on the NinjaTrader support site with the same question and got absolutely no help. I am continually impressed by both the expertise and willingness to help on this site.
Yes this problem I noticed had practically no documentation about it... I ended up having to research the use of the property grid, and tried a variety of approaches until I settled on this one.
Now I'm trying to change the description, making it dynamic as well, but I don't know how to do it exactly.
It is a very large co-incidence that you should ask this on exactly the same night as I am struggling with the same problem.
Unfortunately after many hours I have not found an answer. (C# is not my forte.) The problem seems simply that the complete reflection framework is read-only. The information is retrieved, made available, but can not be updated. In debugging, etc, I think that roughly the code should be as listed below. Unfortunately, this does NOT work.
foreach (PropertyDescriptor property in col)
if (property.Description.Contains("{myToken}"))
foreach (Attribute attribute in property.Attributes)
if (attribute.TypeId == typeof(DescriptionAttribute))
(attribute as DescriptionAttribute).DescriptionValue = "Updated description text.";
The problem is here that DescriptionValue is protected. Also the property.Attributes collection is read-only, it does not even possible to create that new.
With apologies for not posting a working answer, but maybe someone sees an answer.
Background: what I wanted to do, is change the display name in the optimizer so that it can include information about the possible range of values for this parameter. (For what I am trying to do, the parameter range can change dynamically.)
NinjaTrader.Gui.Design.DisplayName attribute has a Name that can be written to. Thanks NinjaTrader.
Based on the original example, I just updated the source for the GetProperties method:
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection originalCollection = TypeDescriptor.GetProperties(GetType(), attributes);
PropertyDescriptor[] newProperties = new PropertyDescriptor[originalCollection.Count];
originalCollection.CopyTo(newProperties, 0);
PropertyDescriptorCollection newCollection = new PropertyDescriptorCollection(newProperties);
foreach (PropertyDescriptor property in newCollection)
foreach (Attribute attribute in property.Attributes)
if (attribute.TypeId == typeof(NinjaTrader.Gui.Design.DisplayNameAttribute))
{
NinjaTrader.Gui.Design.DisplayNameAttribute dn = attribute as NinjaTrader.Gui.Design.DisplayNameAttribute;
dn.Name = dn.Name.Replace("{0}", "abc");
dn.Name = dn.Name.Replace("{1}", "klm");
dn.Name = dn.Name.Replace("{2}", "xyz");
}
return newCollection;
}
The code is not the fastest with the double foreach loop and all the inline string replace sequences, but it does show the the basics of something that seems to work (at this wee hour of the morning).
The purpose of the Universal Timed Alerts is to provide early notification of up to 10 user defined time events, such as Market open, news, reversal periods, no trade periods, etc. The indicator will work on non-time based charts such as Range and Unirenko. …
Be yourself; everyone else is already taken. Oscar Wilde
I'm impressed!!! not only for the coincidence but for your solution, zr6bcm!
Well, maybe is not the most elegant solution with that doble loop, but the most important thing is its functionality.
I'll try this code.
I'd like the improve teh code but I'm not a programmer, I only try to get by and learn more day by day but it's really difficult because the lack of information of certain issues, it's a bit frustrating sometimes...
And regarding to this:
Quoting
I implemented Jeremy's code to great effectiveness in this indicator: ...
I think I'm not allowed to download this file, because I'm not an Elite member.