Stochastic Function

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
report
Newbie
Newbie
Posts: 10
Joined: Fri Oct 21, 2005 4:00 am

Stochastic Function

Post by report » Thu Feb 23, 2006 6:05 pm

Hi,

I would like to know what kin of Stochastic is calculate in TeeChart, fast or slow?
The fast Stochastic is (Close Value - Minimum Value of a Minimum Values list in a period) / ( Maximum Value of a Maximum Values list in a period - Minimum Value of a Minimum Values list in a period) * 100.
I calculate this and did not find the same value of chart with a Stochastic Function.

Thanks in advance.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Feb 24, 2006 8:23 am

Hi report,

According TeeChart's documentation the Stochastic function calculates the highest and lowest value on a given period and then:

value = (close - lowest ) / ( highest - lowest )

Actually this is how values are really calculated:

Code: Select all

function TStochasticFunction.Calculate(Series: TChartSeries; FirstIndex,
  LastIndex: Integer): Double;
var Lows    : TChartValueList;
    Highs   : TChartValueList;
    tmpLow  : Double;
    tmpHigh : Double;
    t       : Integer;
begin
  result:=0;
  With Series do
  Begin
    Lows   :=GetYValueList(TeeMsg_ValuesLow);
    Highs  :=GetYValueList(TeeMsg_ValuesHigh);
    tmpLow :=Lows.Value[FirstIndex];
    tmpHigh:=Highs.Value[FirstIndex];

    for t:=FirstIndex to LastIndex do
    begin
      if Lows.Value[t] <tmpLow  then tmpLow :=Lows.Value[t];
      if Highs.Value[t]>tmpHigh then tmpHigh:=Highs.Value[t];
    end;

    FNums[LastIndex]:=ValueList(Series).Value[LastIndex]-tmpLow;
    FDens[LastIndex]:=tmpHigh-tmpLow;

    if tmpHigh<>tmpLow then
       result:=100.0*(FNums[LastIndex]/FDens[LastIndex]);
  end;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply