public void Test_Finance_ColorDown() { var plt = new ScottPlot.Plot(); // start with default settings var op = new FinancePlot() { OHLCs = new OHLC[] { // open, high, low, close, time, timeSpan new OHLC(273, 275, 264, 265, 1, 1), new OHLC(267, 276, 265, 274, 2.5, 2), new OHLC(277, 280, 275, 278, 4, 1), } }; plt.Add(op); var bmp1 = TestTools.GetLowQualityBitmap(plt); // change the plottable op.ColorDown = System.Drawing.Color.Blue; var bmp2 = TestTools.GetLowQualityBitmap(plt); // measure what changed //TestTools.SaveFig(bmp1, "1"); //TestTools.SaveFig(bmp2, "2"); var before = new MeanPixel(bmp1); var after = new MeanPixel(bmp2); Console.WriteLine($"Before: {before}"); Console.WriteLine($"After: {after}"); Assert.That(after.IsMoreBlueThan(before)); }
/// <summary> /// Add candlesticks to the chart from OHLC (open, high, low, close) data /// </summary> public FinancePlot AddCandlesticks(OHLC[] ohlcs) { FinancePlot plottable = new FinancePlot(ohlcs) { Candle = true, ColorUp = ColorTranslator.FromHtml("#26a69a"), ColorDown = ColorTranslator.FromHtml("#ef5350"), }; Add(plottable); return(plottable); }
public FinancePlot PlotCandlestick( OHLC[] ohlcs, Color?colorUp = null, Color?colorDown = null, bool autoWidth = true, bool sequential = false ) { FinancePlot plottable = new FinancePlot(ohlcs) { Candle = true, Sequential = sequential, ColorUp = colorUp ?? ColorTranslator.FromHtml("#26a69a"), ColorDown = colorDown ?? ColorTranslator.FromHtml("#ef5350") }; Add(plottable); return(plottable); }
public FinancePlot PlotCandlestick( OHLC[] ohlcs, Color?colorUp = null, Color?colorDown = null, bool autoWidth = true, bool sequential = false ) { FinancePlot ohlc = new FinancePlot() { OHLCs = ohlcs, Candle = true, AutoWidth = autoWidth, Sqeuential = sequential, ColorUp = colorUp ?? ColorTranslator.FromHtml("#26a69a"), ColorDown = colorDown ?? ColorTranslator.FromHtml("#ef5350") }; Add(ohlc); return(ohlc); }
public void Test_Finance_AutoWidth() { var plt = new ScottPlot.Plot(); // start with default settings var op = new FinancePlot() { Candle = true, ohlcs = new OHLC[] { // open, high, low, close, time, timeSpan new OHLC(273, 275, 264, 265, 1, 1), new OHLC(267, 276, 265, 274, 4, 1), new OHLC(277, 280, 275, 278, 7, 1), new OHLC(267, 276, 265, 274, 10, 1), } }; plt.Add(op); var bmp1 = TestTools.GetLowQualityBitmap(plt); // change the plottable op.AutoWidth = true; var bmp2 = TestTools.GetLowQualityBitmap(plt); // measure what changed //TestTools.SaveFig(bmp1, "1"); //TestTools.SaveFig(bmp2, "2"); var before = new MeanPixel(bmp1); var after = new MeanPixel(bmp2); Console.WriteLine($"Before: {before}"); Console.WriteLine($"After: {after}"); Assert.That(after.IsDarkerThan(before)); }