I believe that I have found some algorhythm errors in

TTeeFunction.AddPoints(Source:TChartSeries), which is contained in

{*word*249}gine.Pas. I have just purchased TeeCharts Pro Ver. 3, which includes the

source code. I don't know whether there is a user-implementable fix for the

VCL version that comes with Delphi 3.

The first problem lies in the range over which moving functions are

calculated:

procedure TTeeFunction.AddPoints(Source:TChartSeries);

. . . . .

Procedure CalculateMovingFunction;

Var t:Longint;

begin

for t:=FPeriod to Source.Count-1 do

AddFunctionXY( NotMandatorySource[t],

Calculate(Source,t-FPeriod,t));

end;

Assume a DataSource with 9 elements and a period of 3. When AddPoints is

called the first time using the TeeChart's formula, it operates as follows:

for t:= 3 to 8 do

AddFunctionXY(NotMandatorySource[3], Calculate(Source,0,3));

The first problem encountered is that the first value generated by the

algorhythm should be associated with NotMandatorySource[2] (the third

element in the list) rather than NotMandatorySource[3] (the fourth element

in the list).

This is not the only problems. In implementing

TMovingAverageFunction.Calculate( Series:TChartSeries;

First,Last:Longint):Double, the paramters passed by AddFuncitonXY cause

First := 0 and Last := 3, result in the following:

Function

MovingAverageFunction.Calculate( Series:TChartSeries;First,Last:Longint):Dou

ble;

var t:Longint;

tmpSumX,tmpYValue,tmpXValue:Double;

begin

result:=0;

tmpSumX:=0;

// for t:= First to Last do

for t:= 0 to 3 do

begin

tmpYValue:=Series.MandatoryValueList[t];

. . . . .

. . .result:=result+tmpYValue;

end;

. . . . .

. . . result:=result/(3-0+1);

end;

In this example, for a period of three, the moving average is taken of the

sum of four elements divided by a count of four; the error is obvious,

because the algorhythm should be dividing the sum of three elements by a

count of three. I think that the correct formula instead should be:

for t:=Fperiod - 1 to Source.Count-1 do

AddFunctionXY( NotMandatorySource[t], Calculate(Source,t-Fperiod +

1,t));

When first called with a period of 3, the paramter values are:

for t:= 2 to 8 do

AddFunctionXY(NotMandatorySource[2], Calculate(Source,0,2));

When TMovingAverageFunction.Calculate is called the first time, then, it

operates as follows:

for t:= 0 to 2 do

begin

tmpYValue:=Series.MandatoryValueList[t];

. . . . .

. . .result:=result+tmpYValue;

end;

. . . . .

. . . result:=result/(2-0+1);

end;

When called for the last 3 elements in the source list, the paramter values

are:

for t:= 2 to 8 do

AddFunctionXY(NotMandatorySource[8], Calculate(Source,6,8));

Then, when TMovingAverageFunction.Calculate is called the last time, it

operates as follows:

for t:= 6 to 8 do

begin

tmpYValue:=Series.MandatoryValueList[t];

. . . . .

. . .result:=result+tmpYValue;

end;

. . . . .

. . . result:=result/(2-0+1);

end;

As a result of the above modification to the formula, the sum of Fperiod

(three) elements is divided by Fperiod (three) to give a correct moving

average.

I notified the TeeCharts people about this apparent error, and got a message

back that if it is a known error, it probably is contained in a FAQ at

www.TeeMach.Com. I looked in the FAQ, and it isn't there. I don't see how an

owner of the VCL version could fix this problem - it looks like it requires

recompilation of the {*word*249}gine.DCU file.

In addition, although the TeeCharts people promise updated documentation

which will deal with developing custom TChartSeries components, the promises

is "Soon...". The Source Code is almost completely devoid of comments, and

the documentation that exists doesn't really do much for writing new

components. Buying the Source Code, as I have discovered, means time spent

figuring out on your own how the compoenets are put together. That isn't to

say that TeeCharts has engaged in deception - they sold me the source code,

and that's what I got. It just would have been nice to have some better

direction in putting it to use.

Jeffrey Stephens