Overall Statistics
Total Trades
904
Average Win
0.54%
Average Loss
-0.63%
Compounding Annual Return
-1.388%
Drawdown
16.300%
Expectancy
-0.012
Net Profit
-5.247%
Sharpe Ratio
-0.071
Probabilistic Sharpe Ratio
0.924%
Loss Rate
47%
Win Rate
53%
Profit-Loss Ratio
0.85
Alpha
-0.025
Beta
0.138
Annual Standard Deviation
0.094
Annual Variance
0.009
Information Ratio
-0.766
Tracking Error
0.181
Treynor Ratio
-0.048
Total Fees
$1672.40
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();
            }
        }
    }