Is there something I am missing?
Here is the code
#region Variables
// Wizard generated variables
private double stopLoss = 1.5; // Default setting for StopLoss
private int profitTarget = 3; // Default setting for ProfitTarget
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
Add(Stochastics(Close, 0, 14, 3));
Add(ATR(2));
Add(Stochastics(7, 0, 3));
SetStopLoss("long", CalculationMode.Percent, 1.5, false);
SetTrailStop("long", CalculationMode.Percent, 3, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(Stochastics(Close, 0, 14, 3).K, 18, 1)
&& ATR(2)[0] > 0.02)
{
EnterLong(100, "long");
}
// Condition set 2
if (Position.Quantity > 90
&& Stochastics(7, 0, 3).D[2] > 80)
{
ExitLong("100", "long");
}
}
#region Properties
[Description("Stop Loss Pct")]
[GridCategory("Parameters")]
public double StopLoss
{
get { return stopLoss; }
set { stopLoss = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int ProfitTarget
{
get { return profitTarget; }
set { profitTarget = Math.Max(2, value); }
}
#endregion
Comment