Overall Statistics
Total Trades
23
Average Win
3.60%
Average Loss
-2.93%
Compounding Annual Return
1350.534%
Drawdown
25.000%
Expectancy
-0.722
Net Profit
12.404%
Sharpe Ratio
4.618
Probabilistic Sharpe Ratio
54.251%
Loss Rate
88%
Win Rate
12%
Profit-Loss Ratio
1.23
Alpha
4.885
Beta
4.292
Annual Standard Deviation
1.383
Annual Variance
1.913
Information Ratio
4.565
Tracking Error
1.322
Treynor Ratio
1.488
Total Fees
$42.55
Estimated Strategy Capacity
$6900000.00
Lowest Capacity Asset
NQ XPFJZVPGHL35
using System;
using System.Drawing;

namespace QuantConnect.Algorithm.CSharp
{
    public class CasualYellowGreenLemur : QCAlgorithm
    {
        private DateTime _previous;

    	private Symbol _chainSymbol;
        private Symbol _contractSymbol;

        private Dictionary<Symbol, SimpleMovingAverage> _fast = new Dictionary<Symbol, SimpleMovingAverage>();
        private Dictionary<Symbol, SimpleMovingAverage> _slow = new Dictionary<Symbol, SimpleMovingAverage>();

        public override void Initialize() 
        {         
            SetStartDate(2021, 3, 1);
            SetEndDate(2021, 3, 16);
            SetCash(100000);

        	var future = AddFuture(Futures.Indices.NASDAQ100EMini);
        	future.SetFilter(0, 182);
        	_chainSymbol = future.Symbol;
        }
        
        public void OnData(Slice slice) {
           
           if (_previous.Date == Time.Date) return;
           
			FuturesChain chain;
			// Find the contracts in the FuturesChain
			// See docs: https://www.quantconnect.com/docs/data-library/futures
			if (slice.FuturesChains.TryGetValue(_chainSymbol, out chain))
			{
    			var underlying = chain.Underlying;
    			foreach (var contract in chain)
    			{
    				// Create indicators for each contract and save them in dictionaries keyed by Symbol
        			var symbol = contract.Symbol;
        			if (!_slow.ContainsKey(symbol))
        			{
        				_slow[symbol] = SMA(symbol, 72, Resolution.Minute);
        			}
        			
        			if (!_fast.ContainsKey(symbol))
        			{
        				_fast[symbol] = SMA(symbol, 89, Resolution.Minute);
        			}
    			}
    			
    			// For example, select the contract with the earliest expiry
                _contractSymbol = (
                        from futuresContract in chain.OrderBy(x => x.Expiry)
                        where futuresContract.Expiry > Time.Date.AddDays(90)
                        select futuresContract
                    ).FirstOrDefault()?.Symbol;
			}
           
        	if (_contractSymbol == null)
        	{
        		return;
        	}

        	var holdings = Portfolio[_contractSymbol].Quantity;
            var profitloss = Portfolio[_contractSymbol].UnrealizedProfit;

            // we only want to go long if we're currently short or flat
            // if the fast is greater than the slow, we'll go long
            // the fast for the selected contract is found in the dictionary
            if (Portfolio.TotalPortfolioValue > _fast[_contractSymbol])
            {
                var close = Securities[_contractSymbol].Close; 
                Log("BUY  >> " + close);
                MarketOrder(_contractSymbol, 1.0);
                    
                //stoploss
                var stopMarketTicket = StopMarketOrder(_contractSymbol, -1, close * 0.99m);
            }

        	//Plot(_contractSymbol, "Price", slice[_contractSymbol].Price);
            //Plot(_contractSymbol, _fast[_contractSymbol], _slow[_contractSymbol]);

            if (profitloss <= -2000)
            {
                Liquidate(_contractSymbol);
            }

            _previous = Time;
            
            }
        }
    }