Overall Statistics
namespace QuantConnect 
{   
    public class MultiTimeFrameMovingAverageAlgorithm : QCAlgorithm
    {
    	private Dictionary<int, SimpleMovingAverage> _sma = new Dictionary<int, SimpleMovingAverage>();
    	private Dictionary<int, RelativeStrengthIndex> _rsi = new Dictionary<int, RelativeStrengthIndex>();
    	
        public override void Initialize() 
        {
            SetStartDate(2016, 1, 1);
            
            AddEquity("SPY", Resolution.Minute);
            
            foreach(var minute in new int[]{ 5, 10, 15, 20, 30 })
            {
            	// Create Consolidator
            	var consolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(minute));
            	
            	// Create indicators
            	var sma = new SimpleMovingAverage(22);
            	var rsi = new RelativeStrengthIndex(14);
            	
            	// Register indicators to the consolidator to be updated at its frequency
            	RegisterIndicator("SPY", sma, consolidator);
				RegisterIndicator("SPY", rsi, consolidator);
				
				// Add the consolidator to the subscription manager to get updated with data from security 
				SubscriptionManager.AddConsolidator("SPY", consolidator);
				
				// Add SMA and RSI to Dictionaries
				_sma.Add(minute, sma);
            	_rsi.Add(minute, rsi);
            }
        }

        public override void OnData(Slice data) 
        {
            if (!Portfolio.HoldStock) SetHoldings("SPY", 1);
        }
        
        // At end of day, plot the indicators for visual sanity check
        public override void OnEndOfDay()
        {
        	foreach(var kvp in _sma)
        	{
        		Plot("SMA", "M" + kvp.Key, kvp.Value);
        	}
        	
        	foreach(var kvp in _rsi)
        	{
        		Plot("RSI", "M" + kvp.Key, kvp.Value);
        	}
        }
    }
}