Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
12.094%
Drawdown
5.900%
Expectancy
0
Net Profit
0%
Sharpe Ratio
1.737
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.12
Beta
-0.022
Annual Standard Deviation
0.066
Annual Variance
0.004
Information Ratio
-0.649
Tracking Error
0.13
Treynor Ratio
-5.178
Total Fees
$1.00
namespace QuantConnect 
{   
    public class FiveMinuteIndicatorsAlgorithm : QCAlgorithm
    {
    	string _symbol = "SPY";
    	SimpleMovingAverage _sma;
    	TradeBarConsolidator _consolidator;
    
        public override void Initialize() 
        {
            SetStartDate(2013, 1, 1);         
            SetEndDate(2015, 1, 1);
            SetCash(25000);
            AddSecurity(SecurityType.Equity, _symbol, Resolution.Minute);
            
            //Create an indicator object
            _sma = new SimpleMovingAverage(200);
            
            //Create a new 5 minute bar consolidator.
            _consolidator = new TradeBarConsolidator( TimeSpan.FromMinutes(5) );
            
            _consolidator.DataConsolidated += (sender, args) => {
            	//"args" here is a 5 minute trade bar.
            	//Update my SMA with the consolidated 5 minute bars. 
            	_sma.Update(args.Time, args.Close);
            };
            
            //Make sure we pipe SPY data to our consolidator.
            SubscriptionManager.AddConsolidator(_symbol, _consolidator);
        }

		//Handle our data event.
        public void OnData(TradeBars data) 
        {   
        	if (!_sma.IsReady) return;
        	
            if (!Portfolio.HoldStock && data[_symbol].Close > _sma) 
            {
                Order(_symbol,  100);
                Debug(Time.ToString("o") + " Purchased "  + _symbol);
            }
        }
    }
}