My feeble attempt at this is below (only the main sections of the code included), and I'm getting the CS0102 error saying for the properties section saying that Variable0 and 1 are already defined. If I comment out the 'properties' code, I get CS0019 saying I can't apply an operand '*' to type 'int' and 'Ninjatrader.Indicator.ATR'.
Guidance here would be appreciated...Thanks,
KCSystemTrader
#region Variables section...
private int period1 = 25; // Default setting for Period1
private double Variable0 = 0.500; // Default ATR for stop loss
private double Variable1 = 1.000; // Default ATR for take profit
protected override void Initialize() Section...
//Custom code to calculate latest ATR reading and set stop and profit target levels
Add(ATR(Period1)); //This adds the ATR to the chart (I think)
Variable0 = 3 * ATR(Period1);
Variable1 = 6 * ATR(Period1);
//Plug Variable0 and Variable1 calculations into stop and profit target
SetStopLoss("Buy", CalculationMode.Ticks, Variable0, true);
SetStopLoss("Sell", CalculationMode.Ticks, Variable0, true);
SetProfitTarget("Buy", CalculationMode.Ticks, Variable1);
SetProfitTarget("Sell", CalculationMode.Ticks, Variable1);
#region Properties Section...
//Custom Code to define minimum allowable values for Variable0 and Variable1
[Description("ATR For Stop Loss")]
[Category("Parameters")]
public double Variable0
{
get { return Variable0; }
set { Variable0 = Math.Max(0.200, value); }
}
[Description("ATR For Take Profit")]
[Category("Parameters")]
public double Variable1
{
get { return Variable1; }
set { Variable1 = Math.Max(0.400, value); }
}
Comment