public void Test_Bollinger_Bands() { Random rand = new Random(0); double[] xs = DataGen.Consecutive(150); OHLC[] ohlcs = DataGen.RandomStockPrices(rand, xs.Length); // calculate moving average X and Ys (var sma, var bolL, var bolU) = ScottPlot.Statistics.Finance.Bollinger(ohlcs, 20); double[] xs2 = xs.Skip(20).ToArray(); // replace timestamps with a series of numbers starting at 0 for (int i = 0; i < ohlcs.Length; i++) { ohlcs[i].DateTime = DateTime.FromOADate(i); } var plt = new ScottPlot.Plot(600, 400); plt.AddCandlesticks(ohlcs); plt.AddFill(xs2, bolL, xs2, bolU, color: Color.FromArgb(10, Color.Blue)); plt.AddScatter(xs2, bolL, color: Color.Navy, markerSize: 0, label: "Bollinger Bands"); plt.AddScatter(xs2, bolU, color: Color.Navy, markerSize: 0); plt.AddScatter(xs2, sma, color: Color.Navy, markerSize: 0, lineStyle: LineStyle.Dash, label: "SMA 20"); plt.Title("Moving Average and Standard Deviation"); plt.YLabel("Price"); plt.XLabel("Days"); plt.Legend(); plt.AxisAutoX(.03); TestTools.SaveFig(plt); }