Overall Statistics
namespace QuantConnect 
{   
    public class ConsolidatorAlgorithm : QCAlgorithm
    {
    	public Dictionary<Symbol, SymbolData> _symbolData = new Dictionary<Symbol, SymbolData>();
    	public string[] tickers = new string[] { "WFM", "SPY" };
    	public DateTime sampledToday = DateTime.Now;
    	
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize() 
        {
            SetStartDate(2014, 01, 01);         
            SetEndDate(2015, 01, 01);
            SetCash(25000);

            foreach(var ticker in tickers)
            {
            	var security = AddSecurity(SecurityType.Equity, ticker, Resolution.Minute);
            
            	var fifteenMinute = new TradeBarConsolidator(TimeSpan.FromMinutes(15));
            	fifteenMinute.DataConsolidated += OnFifteenMinuteData;
            
            	SubscriptionManager.AddConsolidator(security.Symbol, fifteenMinute);
            	
            	// define our 15 minute money flow indicator
            	var mfi15M = new MoneyFlowIndex(14);
            	RegisterIndicator(security.Symbol, mfi15M, fifteenMinute);
            	
            	_symbolData.Add(security.Symbol, new SymbolData(
            		security.Symbol,
            		MFI(security.Symbol, 14, Resolution.Daily),
            		mfi15M));
			}
        }
        
        // THis is 15 minute activities
        public void OnFifteenMinuteData(object sender, TradeBar bar)
        {
        	if (!_symbolData[bar.Symbol].IsReady) return;
        	
        	var mfi15m = _symbolData[bar.Symbol].Fifteen;
			
			if (mfi15m < 20)
			{
				Order(bar.Symbol, 100);
				Debug(string.Format("Buy {0}. Below 20 mfi15 is {1}", bar.Symbol, mfi15m));
			}
 
            if (mfi15m > 80) 
            {
                Order(bar.Symbol, -100);
                Debug(string.Format("Sell {0}. Above 80 mfi15 is {1}", bar.Symbol, mfi15m));
            }
        }

		//THis is every one minute activities
        public void OnData(TradeBars data) 
        {
        	
        }
    }
    
    public class SymbolData
    {
    	public Symbol Symbol;
    	public MoneyFlowIndex Daily;
    	public MoneyFlowIndex Fifteen;
    	public bool IsReady { get { return Daily.IsReady && Fifteen.IsReady; } }
    	
    	public SymbolData(Symbol symbol, MoneyFlowIndex daily, MoneyFlowIndex fifteen)
    	{
    		Symbol = symbol;
    		Daily = daily;
    		Fifteen = fifteen;
    	}
    	
    	public override string ToString()
    	{
    		return IsReady
    			? string.Format("SymbolData for {0}: Daily: {1}. M15: {2}", Symbol, Daily, Fifteen)
    			: "Indicators are not ready for " + Symbol;
    	}
    }
}