Overall Statistics
namespace QuantConnect
    {   
        public class MaxMinFutures : QCAlgorithm
        {
    		private Maximum _max125;
    		private Maximum _max7;
    		private Symbol symbol;

    		public override void Initialize()
            {
                SetStartDate(2017, 1, 1);         
                symbol = AddEquity("SPY").Symbol;
                var future = AddFuture(Futures.Indices.SP500EMini);
                future.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(60));
    		    
                // Indicators
                EnableAutomaticIndicatorWarmUp = true;
                _max125 = MAX(symbol, 125);
                _max7 = MAX(symbol, 7);
            }
            
            public override void OnData(Slice slice)
            {
            	if (!Portfolio.Invested)
            	{
            		foreach(var chain in slice.FutureChains)
                	{
                        var contract = (
                            from futuresContract in chain.Value.OrderBy(x => x.Expiry)
                            where futuresContract.Expiry > Time.Date.AddDays(5)
                    	    select futuresContract
                    	).FirstOrDefault();

                        if (contract != null)
        	            {
        	            	var _price = Securities[symbol].Price;
        	            	if (_price >= _max125){
        	            		var quantity = 1;
            	            	MarketOrder(contract.Symbol, quantity);
        	            	}
                	    }
                    }
            	}
            }
            
            public override void OnEndOfDay() {
            	Liquidate();
            }
        }
    }