there is compliation error which is not clear.
[Description("This is a sample multi-time frame strategy.")]
public class MultiTimeFrameADX : Strategy
{
#region Variables
// Wizard generated variables
private int fast = 5; // Default setting for Fast
private int slow = 21; // Default setting for Slow
private int ADXPeriod = 18;
// 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 a 5 minute Bars object to the strategy
Add(PeriodType.Minute, 5);
// Add a 15 minute Bars object to the strategy
Add(PeriodType.Minute, 15);
// Note: Bars are added to the BarsArray and can be accessed via an index value
// E.G. BarsArray[1] ---> Accesses the 5 minute Bars object added above
// Add simple moving averages to the chart for display
// This only displays the SMA's for the primary Bars object on the chart
Add(SMA(Fast));
Add(SMA(Slow));
Add(DM(DmiPeriods));
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// OnBarUpdate() will be called on incoming tick events on all Bars objects added to the strategy
// We only want to process events on our primary Bars object (index = 0) which is set when adding
// the strategy to a chart
if (BarsInProgress != 0)
return;
// Checks if the 5 period SMA is above the 50 period SMA on both the 5 and 15 minute time frames
if (SMA(BarsArray[1], Fast)[0] > SMA(BarsArray[1], Slow)[0] && SMA(BarsArray[2], Fast)[0] > SMA(BarsArray[2], Slow)[0])
{
// Checks for a cross above condition of the 5 and 50 period SMA on the primary Bars object and enters long
if (CrossAbove(SMA(Fast), SMA(Slow), 1)
&& (CrossAbove(DM(DmiPeriods).DiPlus, DM(DmiPeriods).DiMinus, 1))
)
EnterLong(10, "SMA");
}
// Checks for a cross below condition of the 5 and 15 period SMA on the 15 minute time frame and exits long
if (CrossBelow(SMA(BarsArray[2], Fast), SMA(BarsArray[2], Slow), 1))
ExitLong(10);
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Fast
{
get { return fast; }
set { fast = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Slow
{
get { return slow; }
set { slow = Math.Max(1, value); }
}
#endregion
}
}
Comment