PDA

View Full Version : User inputs -- manually created (not via wizard)


scriabinop23
05-14-2007, 09:33 PM
I am attempting to create variables that are user settable inputs, basically so I can attempt optimization with a wide range of values. Am having a problem with a script that I am editing manually. my programming background is limited, so please help.

I manually added the variable in #region variables like this:

private int BollThresh = 20;

and added a reference in #region properties near the end of the file like this.

[Description("")]
[Category("Parameters")]
public int BollThresh
{
get { return BollThresh; }
set { BollThresh = Math.Max(1, value); }
}


But the compiler does not like seeing both present. It barks at the properties entry and says "The type 'NinjaTrader.Strategy.LongHammerTrailingStop' already contains a definition for 'BollThresh' Strategy\LongHammerTrailingStop.cs 83 12."

But if I omit the properties entry (which compiler passes the run with), then I won't see the variable listed as an adjustable option.

Note that this code file doesn't have the Wizard XML at the end of it. Is this absolutely necessary to create user input variables? Does that require I create a hollow shell with my named variables the wizard that creates the XML, that I then paste my procedures in?

Any quick and fast workarounds for nonwizard work?

NinjaTrader_Ray
05-14-2007, 09:44 PM
The problem is that you are declaring a property with the exact same name as a variable. Try changing your code to what I have written below. Notice the difference in case. The variable is "bollThresh" while the property is "BollThresh".


private int bollThresh = 20;

[Description("")]
[Category("Parameters")]
public int BollThresh
{
get { return bollThresh; }
set { bollThresh = Math.Max(1, value); }
}

scriabinop23
05-15-2007, 12:30 AM
Thank you very much. very useful. now i'm not dependent on the wizard.