public override void Initialize() { SetStartDate(2013, 10, 7); SetEndDate(2013, 10, 9); SetCash(250000); AddSecurity(SecurityType.Equity, symbol, Resolution.Minute); PSARList.Add(new ParabolicStopAndReverse()); PSARList.Add(new ParabolicStopAndReverse(afStart: 0.1m, afIncrement: 0.1m, afMax: 0.2m)); PSARList.Add(new ParabolicStopAndReverse(afStart: 0.001m, afIncrement: 0.001m, afMax: 0.1m)); RegisterIndicator(symbol, PSARList[0], Resolution.Minute); RegisterIndicator(symbol, PSARList[1], Resolution.Minute); RegisterIndicator(symbol, PSARList[2], Resolution.Minute); testerAcum = 0m; counter = 0; Identity close = new Indicators.Identity("SPY"); RegisterIndicator(symbol, close, Resolution.Minute, Field.Close); var chart = new Chart("SPY"); chart.AddSeries(new Series(close.Name)); chart.AddSeries(new Series(PSARList[0].Name, SeriesType.Scatter)); chart.AddSeries(new Series(PSARList[1].Name, SeriesType.Scatter)); chart.AddSeries(new Series(PSARList[2].Name, SeriesType.Scatter)); PlotIndicator("SPY", close); PlotIndicator("SPY", true, PSARList[0], PSARList[1], PSARList[2]); }
/// <summary> /// Called at the start of your algorithm to setup your requirements: /// </summary> public override void Initialize() { //Set the date range you want to run your algorithm: SetStartDate(startDate); SetEndDate(endDate); //Set the starting cash for your strategy: SetCash(100000); //Add any stocks you'd like to analyse, and set the resolution: // Find more symbols here: http://quantconnect.com/data AddSecurity(SecurityType.Equity, "SPY", resolution: Resolution.Minute); //Chart - Master Container for the Chart: Chart stockPlot = new Chart("Trade Plot", ChartType.Overlay); //On the Trade Plotter Chart we want 3 series: trades and price: Series buyOrders = new Series("Buy", SeriesType.Scatter); Series sellOrders = new Series("Sell", SeriesType.Scatter); Series assetPrice = new Series("Price", SeriesType.Line); stockPlot.AddSeries(buyOrders); stockPlot.AddSeries(sellOrders); stockPlot.AddSeries(assetPrice); AddChart(stockPlot); Chart avgCross = new Chart("Strategy Equity", ChartType.Stacked); Series fastMA = new Series("FastMA", SeriesType.Line); Series slowMA = new Series("SlowMA", SeriesType.Line); avgCross.AddSeries(fastMA); avgCross.AddSeries(slowMA); AddChart(avgCross); resamplePeriod = TimeSpan.FromMinutes((endDate - startDate).TotalMinutes / 2000); }
/// <summary> /// Fetch the updates of the chart, and save the index position. /// </summary> /// <returns></returns> public Chart GetUpdates() { var copy = new Chart(Name, ChartType); try { foreach (var series in Series.Values) { copy.AddSeries(series.GetUpdates()); } } catch (Exception err) { Log.Error("Chart.GetUpdates(): " + err.Message); } return copy; }
public override void Initialize() { SetStartDate(2010, 01, 1); SetEndDate(2012, 12, 31); SetCash(100000); AddSecurity(SecurityType.Equity, symbol, Resolution.Daily); var close = Identity(symbol); LSMA = new LeastSquaresMovingAverage(20); RegisterIndicator(symbol, LSMA, Resolution.Daily, Field.Close); var chart = new Chart("Plot"); chart.AddSeries(new Series(close.Name)); chart.AddSeries(new Series(LSMA.Name)); PlotIndicator("Plot", close); PlotIndicator("Plot", true, LSMA); logResult.AppendLine("Time,Close,LSMA"); }
/// <summary> /// Samples the given charts /// </summary> /// <param name="charts">The charts to be sampled</param> /// <param name="start">The date to start sampling</param> /// <param name="stop">The date to stop sampling</param> /// <returns>The sampled charts</returns> public Dictionary<string, Chart> SampleCharts(IDictionary<string, Chart> charts, DateTime start, DateTime stop) { var sampledCharts = new Dictionary<string, Chart>(); foreach (var chart in charts.Values) { var sampledChart = new Chart(chart.Name, chart.ChartType); sampledCharts.Add(sampledChart.Name, sampledChart); foreach (var series in chart.Series.Values) { var sampledSeries = Sample(series, start, stop); sampledChart.AddSeries(sampledSeries); } } return sampledCharts; }