I am struggling here. The basicTemplateAlgorithm.cs seems running.
I add my own test file RollingWindow.cs and the debug F5 just gave a null reference exception .
public class QCURollingWindow : QCAlgorithm
{
RollingWindow<TradeBar> _window = new RollingWindow<TradeBar>(7);
public override void Initialize()
{
SetStartDate(2013, 10, 07); //Set Start Date
SetEndDate(2013, 10, 11);
SetCash(25000);
AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
}
public void OnData(TradeBars data)
{
//Inject data into the rolling window.
_window.Add(data["SPY"]);
if (!_window.IsReady) return;
if (_window[0].Close > _window[6].Close)
{
SetHoldings("SPY", -0.5);
Debug("Short Stock");
}
else {
SetHoldings("SPY", 0.5);
Debug("Purchased Stock");
}
}
}
I just copied the codes from tutorial and changed the dates as there's only four days' data.