Page 1 of 1

Can I paint graph with gaps for TCandleSeries?

Posted: Tue Jan 19, 2010 8:56 am
by 10551422
Hello. Can I paint graph with gaps for TCandleSeries in CandleStyle := csLine mode? AddNull method doesn't work. Example is attached in candle_test.zip.

Re: Can I paint graph with gaps for TCandleSeries?

Posted: Wed Jan 20, 2010 9:32 am
by yeray
Hi actforex,

No, I'm afraid TCandleseries' csLine mode doesn't allow null points. But you could transform your TCandleseries to be a TLineSeries. Here it is an example from the beginning:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var Series_Candle: TCandleSeries;
    CandleCopy: TChartSeries;
begin
  Chart1.View3D:=false;

  Series_Candle:=Chart1.AddSeries(TCandleSeries.Create(self)) as TCandleSeries;

  Series_Candle.AddCandle(1, 5, 15, 4, 10);
  Series_Candle.AddCandle(2, 8, 10, 1, 6);
  Series_Candle.AddNull(3);
  Series_Candle.AddCandle(4, 8, 14, 5, 10);
  Series_Candle.AddCandle(5, 6, 10, 6, 7);

  CandleCopy:=CloneChartSeries(Series_Candle);
  ChangeSeriesType(CandleCopy,TLineSeries);

  Series_Candle.Active:=false;
end;

Re: Can I paint graph with gaps for TCandleSeries?

Posted: Thu Jan 21, 2010 10:52 am
by 10551422
Thank you, but this is not exactly what's needed. If possible, please include this task in the development plan. This is a minor fix, but it would be very helpful for us.

So far I have managed to solve the problem by actually adding two lines into TCandleSeries.DrawValue:

begin
if IsNull(ValueIndex) then //TF02013524
begin
OldP.X := MaxInt; // (!)
Exit;
end;
...
if FCandleStyle=csLine then // Line
begin
...
if (ValueIndex<>tmpFirst) and (OldP.X <> MaxInt) then // (!)
...

Re: Can I paint graph with gaps for TCandleSeries?

Posted: Thu Jan 21, 2010 3:38 pm
by yeray
Hi actforex,

Thank you for the suggestion. I've added it to the wish list to be studied for inclusion asap (TV52014649).

Re: Can I paint graph with gaps for TCandleSeries?

Posted: Mon Feb 01, 2010 4:06 pm
by narcis
Hi actforex,

Just wanted to let you know that I fixed TV52014649 for the next maintenance release.

You can implemented the fix in DrawValue method pending candles with CandleStyle=csLine like this:

Code: Select all

    if FCandleStyle=csLine then  // Line
    begin
      P:=TeePoint(tmpX,YClose);

      tmpFirst:=FirstDisplayedIndex;

      if (ValueIndex<>tmpFirst) and (not IsNull(ValueIndex)) then
      begin
        if not IsNull(ValueIndex-1) then
        begin
          AssignVisiblePenColor(Self.Pen,tmpColor);
          BackMode:=cbmTransparent;
          if View3D then LineWithZ(OldP,P,MiddleZ)
                    else Line(OldP,P);
        end;

        OldP:=P;
      end
      else if ValueIndex=tmpFirst then OldP:=P;
    end