Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 17.081% Drawdown 18.500% Expectancy 0 Net Profit 87.825% Sharpe Ratio 0.827 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.081 Beta 5.009 Annual Standard Deviation 0.219 Annual Variance 0.048 Information Ratio 0.736 Tracking Error 0.219 Treynor Ratio 0.036 Total Fees $1.00 |
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