Overall Statistics
namespace QuantConnect 
{   
    
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
    	//parameters go here
    	private const string Symbol = "SWN";
       int quantity = 0;
        decimal price = 0;
        decimal tolerance = 0m; //0.1% safety margin in prices to avoid bouncing.
        DateTime sampledToday = DateTime.Now;
        SimpleMovingAverage smaShort;
        SimpleMovingAverage smaLong;
        String symbol = "SWN" ;
        private SimpleMovingAverage fast;
        private SimpleMovingAverage slow;
        
        public override void Initialize() 
        {
			// Code Automatically Generated  
			AddSecurity(SecurityType.Equity, "SWN", Resolution.Minute);
			
			//Set backtest dates here
            SetStartDate(2016, 1, 1);         
            SetEndDate(DateTime.Now.Date.AddDays(-1));
            //Set Backtest cash amount here
            SetCash(5000);
            
            smaShort = SMA(symbol, 100, Resolution.Minute);
            smaLong = SMA(symbol, 200, Resolution.Minute);
           
            
        }

        //Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
        public void OnData(TradeBars data) 
        {   
            // "TradeBars" object holds many "TradeBar" objects: it is a dictionary indexed by the symbol:
            
            
            if (!Portfolio.HoldStock) 
            {
             int quantity = (int)Math.Floor(Portfolio.Cash / data["SWN"].Close);
             if (!smaShort.IsReady) return;
             if(!smaLong.IsReady) return ;
           
           if (smaShort > smaLong && price > smaShort){
           	 Order("SWN",  100); //Order function (Stock,Quantity)
           }
              if (Portfolio.HoldStock && smaShort < smaLong && price < smaShort)
            {
                Liquidate("SWN") ;    
            }
            
          
            
           if (smaShort < smaLong && price < smaShort){
            	Order("SWN", -100);
            }
             if (Portfolio.HoldStock && smaShort > smaLong && price > smaShort)
            {
                Liquidate("SWN") ;    
            }
                //Debug sends messages to the user console: "Time" is the algorithm time keeper object 
                Debug("Purchased SWN on " + Time.ToShortDateString());
                
                //You can also use log to send longer messages to a file. You are capped to 10kb
                //Log("This is a longer message send to log.");
            } 
        }
    }
}