Candle HighLowPen coloring.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Candle HighLowPen coloring.

Post by Snarkle » Mon Aug 09, 2010 7:36 am

Greetings,

Is there a way to make a Candle Stick HighLowPen.Color the same as the Stick color.

example ...
DesiredCandle.png
Desired Candle look
DesiredCandle.png (3.35 KiB) Viewed 5708 times
You can see that the HigLowPen's color is the same as the rest of the candle.

I looked at this example "Welcome !\Chart styles\Financial\Candle (OHLC)\Candle HighLow pen" but it only covers changing ALL the HigLowPen's to one color.

Failing that .. I guess I'll have to color each HigLowPen individually .. any suggestions on where is the best place to do this ... or do I need to do a separate iteration through the Candle series once its drawn ...

Cheers Phil.
--------------------
Cheers Phil.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Candle HighLowPen coloring.

Post by Yeray » Tue Aug 10, 2010 2:48 pm

Hi Phil,

You could use GetPointerStyle event to change the series Pen.Color before drawing each point:

Code: Select all

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            Steema.TeeChart.Styles.Candle Candle1 = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
            Candle1.FillSampleValues(10);
            Candle1.CandleWidth = 15;
            Candle1.UpCloseColor = Color.Green;

            Candle1.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(series1_GetPointerStyle);
        }

        void series1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
        {
            series.Pointer.Pen.Color = e.Color;
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: Candle HighLowPen coloring.

Post by Snarkle » Fri Aug 13, 2010 12:40 am

Thanks Yeray that does the trick.
--------------------
Cheers Phil.

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: Candle HighLowPen coloring.

Post by Snarkle » Fri Aug 13, 2010 5:53 am

Greetings .. back again ... did you miss me? no ?? oh well :-)

On the topic of Coloring candles ... with your kind support I have them looking pretty much as I want them ..
DesiredCandle2.png
DesiredCandle2.png (2.46 KiB) Viewed 5639 times
And happily whatever color the candle is, so is the PointerStyle color ... perfect ...
However ... the candle coloring happens thanks to the

Code: Select all

                    myCandle.Style = CandleStyles.CandleStick;
                    myCandle.UpCloseColor = Color.Green;
                    myCandle.DownCloseColor = Color.Red;
Now when the close price == the open price we like to color our candles grey ... is there a way to color random candles ?

I tried this but just got multicolored Candles ... very pretty .. not so usable ;-)

Code: Select all

for (int index = 0; index < dataList.Count; index++)
            {
                double open = Convert.ToDouble(dataList[index].Open);
                double high = Convert.ToDouble(dataList[index].High);
                double low = Convert.ToDouble(dataList[index].Low);
                double close = Convert.ToDouble(dataList[index].Close);
                DateTime idate = dataList[index].Date;

                // Labels for the X axis.
                labels.Add(idate.ToShortDateString());

                /// Color the pointers for the Candles
                Color pointerColor;
                if (open > close) pointerColor = Color.Red;
                else if (close > open) pointerColor = Color.Green;
                else pointerColor = Color.DarkGray;
                
                myCandle.Colors[index] = pointerColor;
                // Add the data to the Series.
                myCandle.Add(index, open, high, low, close);
            }
--------------------
Cheers Phil.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Candle HighLowPen coloring.

Post by Yeray » Fri Aug 13, 2010 3:59 pm

Hi Phil,

If I understood well, you should use again the GetPointer event:

Code: Select all

         private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            Steema.TeeChart.Styles.Candle Candle1 = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
            Candle1.CandleWidth = 15;
            Candle1.Style = Steema.TeeChart.Styles.CandleStyles.CandleStick;
            Candle1.UpCloseColor = Color.Green;
            Candle1.DownCloseColor = Color.Red;

            //testing values
            Candle1.FillSampleValues(10);
            Candle1.CloseValues[2] = Candle1.OpenValues[2];

            Candle1.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(series1_GetPointerStyle);
        }

        void series1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
        {
            if (series is Steema.TeeChart.Styles.Candle)
            {
                Steema.TeeChart.Styles.Candle candle = series as Steema.TeeChart.Styles.Candle;
                if (candle.CloseValues[e.ValueIndex] == candle.OpenValues[e.ValueIndex])
                    e.Color = Color.Gray;                    
            }
                series.Pointer.Pen.Color = e.Color;
        }
Snarkle wrote:Greetings .. back again ... did you miss me? no ?? oh well :-)
:lol:
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply