Board index » delphi » Candle TDBChart: How I can get real date value in my Candle chart?

Candle TDBChart: How I can get real date value in my Candle chart?

I'm using following approach to make a Candle chart without
weekends/holidays...

Quote
>With database Candle Series, you should unselect the "X" field, and
>use the "XLabels" field instead.

>Series1.XValues.ValueSource := '' ;   <--- no x field
>Series1.XLabelsSource := 'MyDateField' ;         <---- use date field as
>string

>In this way, each record in the table will be assigned a different
>sequential
>integer number ( 0,1,2,3,4,5......  ),  no matter if the difference in dates
>is more
>than one day.  So, if a Friday is point number 111, the Monday will be 112
>(not 114).

Using it, DateValues array property of Candle serie has sequential
number.... Is there any way to I get real(original) date value for a
specified point? Or I'll should to store original date values in a
auxiliar array variable?

I've customized bottom axis label, then they dont contains date
values....

TAS

[]'s
Jorge Kazuo
jka...@nospam.pixelnet.com.br (remove "nospam." to mail me)
PIXEL Tecnologia em Informtica S/C Ltda.
http://www.pixelnet.com.br

 

Re:Candle TDBChart: How I can get real date value in my Candle chart?


Hi Jorge
If you add candle points with sequential "X" values ( 0,1,2,3... )
then the only way to obtain the "Date" associated to each candle is
either using your own array of dates ( Dates:Array[0.1000] of TDateTime ) or
use the "XLabel" as a place to store the dates in string format:

Series1.AddCandle( 0, .....,  '01-03-1998'  );

You can then access the date using this:

Var MyDate:TDateTime ;
MyDate:=StrToDate( Series1.XLabel[ 0  ]  );    <-- from 0 to Count-1

It would be very nice if the axis automatically removed the "gaps" between
friday to sunday, while maintaining the correct datetime spacing and
labelling.
But, what about if a "wednesday" is missing?  Should the axis leave the gap
or
remove it?  What about if two weeks are missing?
The problem removing datetime periods is the calculation needed to obtain
the
"real" position for any given date. The axis should start at the first point
of the Series
(what about more than one series?)  and then traverse all points and check
if the
difference bettwen a point and the previous one is bigger than 1 ( 1= one
day ) or not.
But, somebody can request removing custom gaps (instead of removing periods
of 1 day,
remove several minutes, or hours, or even non-even datetime periods:
10h:33m:22s ).
It's not easy to make a generic algorithm. The best solution to remove
weekends is
to use a sequential value as date.

Regards
David Berneda
www.teemach.com

Jorge Kazuo escribi en mensaje <35108bc3.170056...@forums.borland.com>...

Quote
>I'm using following approach to make a Candle chart without
>weekends/holidays...

>>With database Candle Series, you should unselect the "X" field, and
>>use the "XLabels" field instead.

>>Series1.XValues.ValueSource := '' ;   <--- no x field
>>Series1.XLabelsSource := 'MyDateField' ;         <---- use date field as
>>string

>>In this way, each record in the table will be assigned a different
>>sequential
>>integer number ( 0,1,2,3,4,5......  ),  no matter if the difference in
dates
>>is more
>>than one day.  So, if a Friday is point number 111, the Monday will be 112
>>(not 114).

>Using it, DateValues array property of Candle serie has sequential
>number.... Is there any way to I get real(original) date value for a
>specified point? Or I'll should to store original date values in a
>auxiliar array variable?

>I've customized bottom axis label, then they dont contains date
>values....

>TAS

>[]'s
>Jorge Kazuo
>jka...@nospam.pixelnet.com.br (remove "nospam." to mail me)
>PIXEL Tecnologia em Informtica S/C Ltda.
>http://www.pixelnet.com.br

Re:Candle TDBChart: How I can get real date value in my Candle chart?


Hi Jorge
If you add candle points with sequential "X" values ( 0,1,2,3... )
then the only way to obtain the "Date" associated to each candle is
either using your own array of dates ( Dates:Array[0.1000] of TDateTime ) or
use the "XLabel" as a place to store the dates in string format:

Series1.AddCandle( 0, .....,  '01-03-1998'  );

You can then access the date using this:

Var MyDate:TDateTime ;
MyDate:=StrToDate( Series1.XLabel[ 0  ]  );    <-- from 0 to Count-1

It would be very nice if the axis automatically removed the "gaps" between
friday to sunday, while maintaining the correct datetime spacing and
labelling.
But, what about if a "wednesday" is missing?  Should the axis leave the gap
or
remove it?  What about if two weeks are missing?
The problem removing datetime periods is the calculation needed to obtain
the
"real" position for any given date. The axis should start at the first point
of the Series
(what about more than one series?)  and then traverse all points and check
if the
difference bettwen a point and the previous one is bigger than 1 ( 1= one
day ) or not.
But, somebody can request removing custom gaps (instead of removing periods
of 1 day,
remove several minutes, or hours, or even non-even datetime periods:
10h:33m:22s ).
It's not easy to make a generic algorithm. The best solution to remove
weekends is
to use a sequential value as date.

Regards
David Berneda
www.teemach.com

Jorge Kazuo escribi en mensaje <35108bc3.170056...@forums.borland.com>...

Quote
>I'm using following approach to make a Candle chart without
>weekends/holidays...

>>With database Candle Series, you should unselect the "X" field, and
>>use the "XLabels" field instead.

>>Series1.XValues.ValueSource := '' ;   <--- no x field
>>Series1.XLabelsSource := 'MyDateField' ;         <---- use date field as
>>string

>>In this way, each record in the table will be assigned a different
>>sequential
>>integer number ( 0,1,2,3,4,5......  ),  no matter if the difference in
dates
>>is more
>>than one day.  So, if a Friday is point number 111, the Monday will be 112
>>(not 114).

>Using it, DateValues array property of Candle serie has sequential
>number.... Is there any way to I get real(original) date value for a
>specified point? Or I'll should to store original date values in a
>auxiliar array variable?

>I've customized bottom axis label, then they dont contains date
>values....

>TAS

>[]'s
>Jorge Kazuo
>jka...@nospam.pixelnet.com.br (remove "nospam." to mail me)
>PIXEL Tecnologia em Informtica S/C Ltda.
>http://www.pixelnet.com.br

Re:Candle TDBChart: How I can get real date value in my Candle chart?


Quote
In article <6er28a$2...@forums.borland.com>, David Berneda wrote:
> The best solution to remove
> weekends is
> to use a sequential value as date.

That's true. I did that, and used a TList containing the dates for each
sequence.  However, it really complicated my life when I had to
implement dragging series from one chart onto another, and calculate
the matching between the indices in each chart!  Do-able, but painful.  
I think it'd be fine to offer two options - a) use all TDateTimes as
given, displaying all gaps and b) removing all gaps.  Then, anyone who
had more specific requirements could go the index route.

I have a couple of other requests.

(i) On a particular chart, I have yvalues that are integers, but I have
a strange way of displaying them (e.g., integers representing 32/nd of
a point in a stock, and I'd display 3202 as 100-02).  If I'm in
OnGetAxisLabel, I only get passed the default *string* representation -
I have to make sure it's formatted only as '#', convert to an integer
using StrToInt, and then re-convert to my type.  It'd be great if
OnGetAxisLabel could pass me the *value* of the point it's currently
computing a label for.  Maybe you could add OnGetAxisLabelEx to the
next version, and users could choose between them?

(ii) Finally, rather than use two charts for a given display of related
information, I recently did the following - I artifically lowered the
left axis minimum, raised the right axis maximum, and plotted the
series on the same chart using the left axis for one, and the right
axis for the other (so I'd get series on the same window, but stacked
rather than overlapping).  Of course, if I now turn on the grid lines
for the axes, they clash.  

Question:  Would it be possible to add an option for the grid property
of an axis so it'd only draw its gridlines for axis values within the
range of the currently added series connected to that axis?

Regards, Jim.
--
Sat, 21 Mar 1998 13:15 EST
Jim O'Brien, R&D, PTT, Inc.
wiz...@remove-this-prefix.ptti.com  +1 (212) 972-1702

Other Threads