Strategy: I am on an MSFT chart and want to go long if 1) close price of MSFT is > 20 SMA and 2) second instrument (^VIX) closing price is < 50 SMA of the second instrument (VIX).
My Code is as follows but not sure where the error is or how to fix it even after I look at the error I get when trying to compile ( CS0021 error).
protected override void Initialize()
{
// Add Instrument ^VIX daily Bars object to the strategy
Add("^VIX", PeriodType.Day, 1);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1: chart instrument close > chart instrument 20 SMA and close instrument 2 (VIX) is below 50 SMA instrument 2 1 period ago.
if (Close[0] > SMA(20)[0]
&& Close[1][0] < SMA(BarsArray[1],50)[1] )
{
EnterLong(DefaultQuantity, "");
}
Comment