Page 1 of 1

Candle HighLowPen coloring.

Posted: Mon Aug 09, 2010 7:36 am
by 8751509
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 5706 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.

Re: Candle HighLowPen coloring.

Posted: Tue Aug 10, 2010 2:48 pm
by yeray
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;
        }

Re: Candle HighLowPen coloring.

Posted: Fri Aug 13, 2010 12:40 am
by 8751509
Thanks Yeray that does the trick.

Re: Candle HighLowPen coloring.

Posted: Fri Aug 13, 2010 5:53 am
by 8751509
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 5637 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);
            }

Re: Candle HighLowPen coloring.

Posted: Fri Aug 13, 2010 3:59 pm
by yeray
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: