// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class donchian : Strategy
{
#region Variables
// Wizard generated variables
private int donchianleveltop = 40; // Default setting for Donchianleveltop
private int donchianlevelbottom = 10; // Default setting for Donchianlevelbottom
private int stoploss = 10; // 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()
{
SetTrailStop("", CalculationMode.Percent, Stoploss, true);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (High[0] >= DonchianChannel(Donchianleveltop).Upper[0])
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (Low[0] <= DonchianChannel(Donchianlevelbottom).Lower[0])
{
ExitLong("", "");
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public int Donchianleveltop
{
get { return donchianleveltop; }
set { donchianleveltop = Math.Max(1, value); }
}
[Description("")]
[Category("Parameters")]
public int Donchianlevelbottom
{
get { return donchianlevelbottom; }
set { donchianlevelbottom = Math.Max(1, value); }
}
[Description("")]
[Category("Parameters")]
public int Stoploss
{
get { return stoploss; }
set { stoploss = Math.Max(1, value); }
}
#endregion

Comment