I created with the Wizard the following code:
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class AAAStopLossSSMAcross : Strategy
{
#region Variables
// Wizard generated variables
private int fast = 5; // Default setting for Fast
private int slow = 10; // Default setting for Slow
private double stopLoss = 0; // Default setting for StopLoss
// 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(SMMA(Close, Fast));
Add(SMMA(Slow));
SetTrailStop("BuyIt", CalculationMode.Percent, StopLoss, true);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(SMMA(Close, Fast), SMMA(Slow), 1))
{
EnterLong(DefaultQuantity, "BuyIt");
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public int Fast
{
get { return fast; }
set { fast = Math.Max(1, value); }
}
[Description("")]
[Category("Parameters")]
public int Slow
{
get { return slow; }
set { slow = Math.Max(1, value); }
}
[Description("")]
[Category("Parameters")]
public double StopLoss
{
get { return stopLoss; }
set { stopLoss = Math.Max(-10, value); }
}
#endregion
}
}
Comment