CandleStickSeries multiple colors

Oct 7, 2013 at 5:21 AM
I am using WPF and have looked at all of the sample code as well as the example application and I cannot figure out a way to get green bars when the close is greater than the open and red bars when the close is less than the open.

I'm starting to think this functionality is not available at the individual point level (O, H, L C in this example). Is this the case?

Thank you.
decipher
Coordinator
Oct 7, 2013 at 4:51 PM
I added two new properties for the fill color: IncreasingFill and DecreasingFill
Oct 8, 2013 at 7:12 AM
Edited Oct 8, 2013 at 7:13 AM
Thank you for adding this. I notice it works fine in the winform examples but I can't get it to work in my WPF code.
          // Create the plot model
            PlotModel pm = new PlotModel("Minute Data for " + cboDates.SelectedItem.ToString());// { LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.RightTop, LegendOrientation = LegendOrientation.Vertical };

            var timeSpanAxis1 = new TimeSpanAxis { Position = AxisPosition.Bottom, StringFormat = "hh:mm" };
            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis { Position = AxisPosition.Left };
            pm.Axes.Add(linearAxis1);
            var csSeries = new CandleStickSeries
            {
                CandleWidth = 1,
                IncreasingFill = OxyColors.DarkGreen,
                DecreasingFill = OxyColors.Red,
                DataFieldX = "QTime",
                DataFieldHigh = "H",
                DataFieldLow = "L",
                DataFieldOpen = "O",
                DataFieldClose = "C",
                TrackerFormatString = "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
                ItemsSource = lstMinRec
            };
Coordinator
Oct 8, 2013 at 4:08 PM
The output should be the same on any platform!

Note that CandleWidth is in screen units - I think it you should use a larger number.
I have not tested with a TimeSpanAxis, there might be an issue there.
Can you include some data that we can use in an example?
I added a small example using a DateTimeAxis.
Oct 8, 2013 at 5:08 PM
Edited Oct 8, 2013 at 5:09 PM
The CandleWidth was the problem. When I increased it the colors showed up. One thing I noticed is the colors appear to be reversed. For IncreasingFill I would expect green and for DecreasingFill I would expect red. Increasing would be classified as the close value of the bar being greater than the open value of the bar.
 List<MinuteRec> lst = new List<MinuteRec>
            {
                new MinuteRec { QTime = TimeSpan.Parse("06:31:00"), O = 1672.5000, H = 1673.5000, L = 1671.7500, C = 1672.7500 }, 
                new MinuteRec { QTime = TimeSpan.Parse("06:32:00"), O = 1672.5000, H = 1673.5000, L = 1672.5000, C = 1672.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:33:00"), O = 1672.5000, H = 1672.7500, L = 1670.7500, C = 1671.2500 },
                new MinuteRec { QTime = TimeSpan.Parse("06:34:00"), O = 1671.2500, H = 1671.2500, L = 1670.2500, C = 1670.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:35:00"), O = 1670.7500, H = 1671.7500, L = 1670.5000, C = 1671.2500 },
                new MinuteRec { QTime = TimeSpan.Parse("06:36:00"), O = 1671.0000, H = 1672.5000, L = 1671.0000, C = 1672.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:37:00"), O = 1672.5000, H = 1673.0000, L = 1672.0000, C = 1673.0000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:38:00"), O = 1672.7500, H = 1673.2500, L = 1672.5000, C = 1672.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:39:00"), O = 1672.5000, H = 1672.7500, L = 1671.2500, C = 1671.2500 },
                new MinuteRec { QTime = TimeSpan.Parse("06:40:00"), O = 1671.2500, H = 1672.5000, L = 1671.0000, C = 1672.0000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:41:00"), O = 1672.2500, H = 1672.5000, L = 1671.2500, C = 1672.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:42:00"), O = 1672.2500, H = 1672.5000, L = 1671.5000, C = 1671.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:43:00"), O = 1671.5000, H = 1671.7500, L = 1670.5000, C = 1671.0000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:44:00"), O = 1670.7500, H = 1671.7500, L = 1670.7500, C = 1671.7500 },
                new MinuteRec { QTime = TimeSpan.Parse("06:45:00"), O = 1672.0000, H = 1672.2500, L = 1671.5000, C = 1671.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:46:00"), O = 1671.7500, H = 1671.7500, L = 1671.0000, C = 1671.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:47:00"), O = 1671.7500, H = 1672.2500, L = 1671.5000, C = 1671.7500 },
                new MinuteRec { QTime = TimeSpan.Parse("06:48:00"), O = 1671.7500, H = 1672.7500, L = 1671.7500, C = 1672.5000 },
                new MinuteRec { QTime = TimeSpan.Parse("06:49:00"), O = 1672.2500, H = 1673.7500, L = 1672.2500, C = 1673.7500 },
                new MinuteRec { QTime = TimeSpan.Parse("06:50:00"), O = 1673.7500, H = 1675.0000, L = 1673.5000, C = 1675.0000 }
                    
            };

            // Create the plot model
            PlotModel pm = new PlotModel("Minute Data");

            var timeSpanAxis1 = new TimeSpanAxis { Position = AxisPosition.Bottom, StringFormat = "hh:mm" };
            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis { Position = AxisPosition.Left };
            pm.Axes.Add(linearAxis1);
            var csSeries = new CandleStickSeries
            {
                CandleWidth = 5,
                Color = OxyColors.DarkGray,
                IncreasingFill = OxyColors.DarkGreen,
                DecreasingFill = OxyColors.Red,
                DataFieldX = "QTime",
                DataFieldHigh = "H",
                DataFieldLow = "L",
                DataFieldOpen = "O",
                DataFieldClose = "C",
                TrackerFormatString = "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
                ItemsSource = lst
            };
            pm.Series.Add(csSeries);
Image
Nov 7, 2013 at 1:21 PM
Edited Nov 9, 2013 at 7:27 PM
These should be present on the HighLowSeries too.

Also, some people have different meanings of increasing and decreasing. Some compare close values of two candles instead the open and close. It will be nice to be able to determine the color by a custom calculation. Another more customizable approach is to have a separate series that determines the color of each candle/OHLC.

Any suggestions how to achieve this?

EDIT: A fine example of what I mean:

http://support.stockcharts.com/entries/20591-What-does-a-solid-black-or-hollow-red-candlestick-mean-

My thoughts on this are to add another series specific to this data. Then have an axis that support colors for a specific value. Much like scatter plot with colored axes but for candlesticks and HighLowSeries