コード例 #1
0
        public void ExecuteRecipe(Plot plt)
        {
            OHLC[] prices = DataGen.RandomStockPrices(null, 30, TimeSpan.FromMinutes(5));
            var    fp     = plt.AddCandlesticks(prices);

            fp.WickColor = Color.Black;
        }
コード例 #2
0
        public void ExecuteRecipe(Plot plt)
        {
            OHLC[] prices = DataGen.RandomStockPrices(null, 60, TimeSpan.FromDays(1));

            // add the OHLCs to the plot and the horizontal axis to display DateTime tick labels
            plt.AddCandlesticks(prices);
            plt.XAxis.DateTimeFormat(true);
        }
コード例 #3
0
        public void ExecuteRecipe(Plot plt)
        {
            OHLC[] prices = DataGen.RandomStockPrices(null, 30);
            plt.AddCandlesticks(prices);

            // manually indicate where axis ticks should be and what their labels should say
            double[] tickPositions = { 0, 6, 13, 20, 27 };
            string[] tickLabels    = { "Sep 23", "Sep 30", "Oct 7", "Oct 14", "Oct 21" };
            plt.XTicks(tickPositions, tickLabels);
        }
コード例 #4
0
ファイル: Finance.cs プロジェクト: valmac/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            OHLC[] prices = DataGen.RandomStockPrices(null, 30, TimeSpan.FromMinutes(5));
            plt.AddCandlesticks(prices);
            plt.XAxis.DateTimeFormat(true);

            plt.YAxis.Ticks(false);
            plt.YAxis2.Ticks(true);
            plt.YAxis2.Label("Price (USD)");
        }
コード例 #5
0
        public void ExecuteRecipe(Plot plt)
        {
            OHLC[] ohlcs      = DataGen.RandomStockPrices(null, 100);
            var    candlePlot = plt.AddCandlesticks(ohlcs);

            var bol = candlePlot.GetBollingerBands(20);

            plt.AddScatterLines(bol.xs, bol.sma, Color.Blue);
            plt.AddScatterLines(bol.xs, bol.lower, Color.Blue, lineStyle: LineStyle.Dash);
            plt.AddScatterLines(bol.xs, bol.upper, Color.Blue, lineStyle: LineStyle.Dash);
        }
コード例 #6
0
        public void ExecuteRecipe(Plot plt)
        {
            OHLC[] ohlcs      = DataGen.RandomStockPrices(null, 75);
            var    candlePlot = plt.AddCandlesticks(ohlcs);

            var sma8 = candlePlot.GetSMA(8);

            plt.AddScatterLines(sma8.xs, sma8.ys, Color.Blue, 2);

            var sma20 = candlePlot.GetSMA(20);

            plt.AddScatterLines(sma20.xs, sma20.ys, Color.Navy, 2);
        }
コード例 #7
0
        public void ExecuteRecipe(Plot plt)
        {
            // add some random candles
            OHLC[]   prices     = DataGen.RandomStockPrices(null, 100, TimeSpan.FromMinutes(5));
            double[] xs         = prices.Select(x => x.DateTime.ToOADate()).ToArray();
            var      candlePlot = plt.AddCandlesticks(prices);

            candlePlot.YAxisIndex = 1;

            plt.XAxis.DateTimeFormat(true);

            // add SMA indicators for 8 and 20 days
            var sma8      = candlePlot.GetSMA(8);
            var sma20     = candlePlot.GetSMA(20);
            var sma8plot  = plt.AddScatterLines(sma8.xs, sma8.ys, Color.Cyan, 2, label: "8 day SMA");
            var sma20plot = plt.AddScatterLines(sma20.xs, sma20.ys, Color.Yellow, 2, label: "20 day SMA");

            sma8plot.YAxisIndex  = 1;
            sma20plot.YAxisIndex = 1;

            // customize candle styling
            candlePlot.ColorDown = ColorTranslator.FromHtml("#00FF00");
            candlePlot.ColorUp   = ColorTranslator.FromHtml("#FF0000");

            // customize figure styling
            plt.Layout(padding: 12);
            plt.Style(figureBackground: Color.Black, dataBackground: Color.Black);
            plt.Frameless();
            plt.XAxis.TickLabelStyle(color: Color.White);
            plt.XAxis.TickMarkColor(ColorTranslator.FromHtml("#333333"));
            plt.XAxis.MajorGrid(color: ColorTranslator.FromHtml("#333333"));

            // hide the left axis and show a right axis
            plt.YAxis.Ticks(false);
            plt.YAxis.Grid(false);
            plt.YAxis2.Ticks(true);
            plt.YAxis2.Grid(true);
            plt.YAxis2.TickLabelStyle(color: ColorTranslator.FromHtml("#00FF00"));
            plt.YAxis2.TickMarkColor(ColorTranslator.FromHtml("#333333"));
            plt.YAxis2.MajorGrid(color: ColorTranslator.FromHtml("#333333"));

            // customize the legend style
            var legend = plt.Legend();

            legend.FillColor    = Color.Transparent;
            legend.OutlineColor = Color.Transparent;
            legend.Font.Color   = Color.White;
            legend.Font.Bold    = true;
        }
コード例 #8
0
ファイル: Finance.cs プロジェクト: valmac/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            // generate sample stock prices
            OHLC[]   ohlcs = DataGen.RandomStockPrices(null, 100);
            double[] xs    = DataGen.Consecutive(ohlcs.Length);

            // calculate the bands and the time range they cover
            double[] xs2 = xs.Skip(20).ToArray();
            (var sma, var bolL, var bolU) = Statistics.Finance.Bollinger(ohlcs, 20);

            // plot technical indicators as scatter plots above the financial chart
            plt.AddCandlesticks(ohlcs);
            plt.AddScatter(xs2, sma, markerSize: 0, color: Color.Blue);
            plt.AddScatter(xs2, bolL, markerSize: 0, color: Color.Blue, lineStyle: LineStyle.Dash);
            plt.AddScatter(xs2, bolU, markerSize: 0, color: Color.Blue, lineStyle: LineStyle.Dash);
        }
コード例 #9
0
ファイル: Finance.cs プロジェクト: valmac/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            // generate sample stock prices
            OHLC[]   ohlcs = DataGen.RandomStockPrices(null, 75);
            double[] xs    = DataGen.Consecutive(ohlcs.Length);

            // calculate SMAs of different durations using helper methods
            double[] sma8xs  = xs.Skip(8).ToArray();
            double[] sma8ys  = Statistics.Finance.SMA(ohlcs, 8);
            double[] sma20xs = xs.Skip(20).ToArray();
            double[] sma20ys = Statistics.Finance.SMA(ohlcs, 20);

            // plot technical indicators as scatter plots above the financial chart
            plt.AddCandlesticks(ohlcs);
            plt.AddScatter(sma8xs, sma8ys, markerSize: 0, color: Color.Blue, lineWidth: 2);
            plt.AddScatter(sma20xs, sma20ys, markerSize: 0, color: Color.Navy, lineWidth: 2);
        }
コード例 #10
0
 public void ExecuteRecipe(Plot plt)
 {
     // OHLCs are open, high, low, and closing prices for a time range.
     OHLC[] prices = DataGen.RandomStockPrices(null, 60);
     plt.AddCandlesticks(prices);
 }