Overall Statistics
namespace QuantConnect.Algorithm.CSharp
{
    
    public class HL_BaseAlgorithm : QCAlgorithm
    
    {
        //Define Symbols
        private Symbol _symbol = QuantConnect.Symbol.Create("googl", SecurityType.Equity, Market.USA);
        //Define Lists
        private List<TradeBar> _TradeBar_window;
        private List <TradeBar> ListOfMax = new List<TradeBar>();
        private List <TradeBar> ListOfMin = new List<TradeBar>();
        
        //Define Parameters
        private int BackwardLookingPeriod = 200;
        private int WarmUpPeriod = 0 ;
        private int minutesToExecute = 10;
        private decimal _priceOpen ;
        private decimal _priceClose ;
        private decimal _pricePrice ;
        private Boolean maxCounter = false;
        private decimal PurchaseClose;
        //Define Orders
        private OrderTicket CurrentOrder;
    	private OrderTicket StopLoss;
    	private OrderTicket ProfitTarget;
    	
        

        public override void Initialize()
        {
            SetStartDate(2014, 01, 01);  //Set Start Date
            SetEndDate(2018, 01, 01);    //Set End Date
            SetCash(100000);             //Set Strategy Cash
            
            AddEquity(_symbol, Resolution.Daily);
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Daily);
            
            	    
            //INITIALISE THE HISTORICAL PERIOD//
            
    		_TradeBar_window = new List<TradeBar>(BackwardLookingPeriod);
    		
    		IEnumerable<TradeBar> slices = History(_symbol, BackwardLookingPeriod);
    
    	foreach (TradeBar bar in slices) {
    		_TradeBar_window.Add(bar);
    	}
    	Debug("The first element in the history at the start is at: " + _TradeBar_window.First().Time);
    		Debug("The last element in the history at the start is at: " + _TradeBar_window.Last().Time);
    	//SET WARMUP
    	
    		SetWarmUp(WarmUpPeriod);
    	
    	Debug("Setting warm up");
    	
    	//SCHEDULE THE ACTUAL CODE TO HAPPEN AND WHEN IT HAPPENS //
            
        Schedule.On(   DateRules.EveryDay(_symbol), 
    	
    	TimeRules.AfterMarketOpen(_symbol,minutesToExecute), //Execute the function at the start of the day 
    	//                                                     x minutes in....
    	EveryDayOnMarketOpen     );
    	
    	}
    	
    	//DEFINE THE FUNCTION THAT YOU CALL ON THE MARKET
    	
    	public void EveryDayOnMarketOpen(){
    		
    		//Calculate Indicators
    		
    	var history = History(_symbol,1,Resolution.Daily);
    
    	foreach (var i in history) {
    		_TradeBar_window.Add(i);	}//END OF FOR EACH
    	_priceOpen = _TradeBar_window.Last().Open; //Price check; ensure that the price is the same as the stockplot
        _priceClose = _TradeBar_window.Last().Close;
        _pricePrice = _TradeBar_window.Last().Price;
    		ListOfMax.Clear();
    		ListOfMin.Clear();
    		maxCounter = false;
    		
    		//Calculate parameters for trading rule
    		
    		//Introduce trading rule
  
  
  
  
    		if ( !Portfolio.HoldStock) {
    		
    		PurchaseClose = _TradeBar_window.Last().Close;
    			var quantity = (int)Math.Floor(Portfolio.Cash / PurchaseClose);
    			CurrentOrder = Order(_symbol, quantity);
    		
    	} else {
    		
    		
    		}	
    	
    
    		
       
    }//END OF FUNCTION DEFINITION
    public void OnData (TradeBars data){
    	
    }
    
    //Define the plotting of indicators
    public override void OnEndOfDay(){
        
      Plot("Purchase Prices", "Price Open",_priceOpen);
      Plot("Purchase Prices", "Price Close",_priceClose);
       Plot("Purchase Prices", "Price Price",_pricePrice);
        }//END OF BASIC TEMPLATE ALGORITHM
    
    
    }
    
    
        
    }// END OF NAMESPACE