Page 1 of 1

Stochastic Function

Posted: Thu Feb 23, 2006 6:05 pm
by 9343900
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.

Posted: Fri Feb 24, 2006 8:23 am
by narcis
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;