View Full Version : How to make parameter read-only
cassb
04-13-2010, 07:14 PM
In v6.5, I could make a parameter for my indicators read-only (not allowing input) like this:
[Description("Use this web site for support")]
[GridCategory(" Dashboard")]
[Gui.Design.DisplayNameAttribute(" Support")]
public string WebSite
{
get { return "http://protradingtools.com"; }
}
In v7.0, I get an error when I use this technique: Property or indexer 'NinjaTrader.Indicator.ptt_RefreshMatrix.WebSite' cannot be assigned to -- it is read only
How do you do this in v7.0?
Thanks!
NinjaTrader_Bertrand
04-14-2010, 04:32 AM
cassb, which NT 7 version do you use? Your snippet compiles and works for me here.
cassb
04-14-2010, 06:36 AM
cassb, which NT 7 version do you use? Your snippet compiles and works for me here.
I'm using Beta 14. Something seems to be screwed up with my installation then, because I have another thread here about the "enum" function not working in NT7 either. Hm. The weird thing is that this all used to work OK on a previous beta version back in January, but last week I formatted my hard drive and reinstalled NT6.5 and NT7 and now it doesn't compile any more. I'm not sure how to troubleshoot it, either. Can you help?
NinjaTrader_Bertrand
04-14-2010, 06:39 AM
Are you using any custom assemblies not protected via Protector 31 and beta 14?
It would help if you send me a full screenshot of the errors you get with your trace and logs to support at ninjatrader dot com Attn Bertrand.
Thanks
cassb
04-14-2010, 07:55 AM
Are you using any custom assemblies not protected via Protector 31 and beta 14?
It would help if you send me a full screenshot of the errors you get with your trace and logs to support at ninjatrader dot com Attn Bertrand.
Thanks
Here you go. This is the indicator code and the compile error I get. I can send you the log and trace files too if you want. Just let me know.
Thanks!
Bryan
NinjaTrader_Bertrand
04-14-2010, 09:01 AM
For this input please use only 'Category' and not 'GridCategory', the attached should compile well.
cassb
04-14-2010, 10:29 AM
For this input please use only 'Category' and not 'GridCategory', the attached should compile well.
Yes, it does compile with [Category], but Dierk says not to use that in version 7 any more and to only use [GridCategory]. So what should I do?
NinjaTrader_Bertrand
04-14-2010, 10:34 AM
http://www.ninjatrader-support2.com/vb/showpost.php?p=157543&postcount=14
Please see this post on GridCategory vs Category usage.
cassb
04-14-2010, 11:59 AM
http://www.ninjatrader-support2.com/vb/showpost.php?p=157543&postcount=14
Please see this post on GridCategory vs Category usage.
Josh said: "Development says that GridCategory should be used only for parameters (what will be listed in your indicator method). Should you want something that is not a parameter property you should use Category."
So are you saying that the 'read-only' parameter that I want to display in my indicator method is treated as something that is not a parameter property then?
NinjaTrader_Josh
04-14-2010, 02:18 PM
cassb,
Please clarify what exactly you are trying to do. A parameter by definition is something that is changeable and those are set to GridCategory. If you want something that is not part of your indicator method call then you would use Category.
cassb
04-14-2010, 02:39 PM
cassb,
Please clarify what exactly you are trying to do. A parameter by definition is something that is changeable and those are set to GridCategory. If you want something that is not part of your indicator method call then you would use Category.
Hi Josh. I just wanted an informational piece to be displayed in the list of parameters to point users to our web site for support. I didn't see any other way to do that in the indicator itself (to have informational data display). I saw you had other std indicators that have read-only parameters in some cases, so I put that idea to my own use.
Bryan
NinjaTrader_Josh
04-14-2010, 04:02 PM
cassb,
Would the indicator description field work better for this? That will show up as they click your indicator in the bottom right gray space below the properties grid.
cassb
04-14-2010, 08:12 PM
cassb,
Would the indicator description field work better for this? That will show up as they click your indicator in the bottom right gray space below the properties grid.
No, we use that "Label" parameter to describe what the indicator does. I like the look of the read-only parameter for information like our support web page.
Bryan
NinjaTrader_Bertrand
04-15-2010, 09:21 AM
cassb, curious have you tried a readonly string?
cassb
04-15-2010, 10:06 AM
cassb, curious have you tried a readonly string?
What do you mean?
NinjaTrader_Bertrand
04-15-2010, 10:12 AM
Strings can use a modifier readonly in C#, but not allowed in the Properties...try this...add a private string variable that 'fills' your website back in when someone deletes it -
private string webSite = http://protradingtools.com;
Works in my quick test here.