Double Smoothed Stochastics

Kant-en-klare, geteste indicatoren en handelssystemen
Plaats reactie
Eric
Berichten: 3332
Lid geworden op: za sep 10, 2005 2:41 am
Locatie: Den Haag

Double Smoothed Stochastics

Bericht door Eric »

De Double Stochastics (of double smoothed stochastics) van Walter Bressert.

Code: Selecteer alles

{- Filename: Double Stochastics -}

function PctK(aHigh, aLow, aClose: TSeries; aLength: integer): TSeries;
var
  sHigh, sLow, sLowDiff: TSeries;
  Deler: real;
  Count, i: integer;
begin
  Count := GetArrayLength(aClose);
  sHigh := HighSeries(aHigh, aLength);
  sLow := LowSeries(aLow, aLength);
  sLowDiff := SubtractSeries(aClose, sLow);
  Result := CreateSeries(Count);

  for i:=FirstValidIndex(sHigh) to Count-1 do
  begin
    Deler := sHigh[i] - sLow[i];
    if Deler = 0 then Deler := 1;
    Result[i] := sLowDiff[i] / Deler * 100;
  end;
end;

var
  nLength, nUpGrens, nDnGrens: integer;
  sTemp, sDS: TSeries;
begin
{ Indicator parameters }
  nLength := CreateParameterInteger('Length', 1, 999, 10, true);
  nUpGrens := CreateParameterInteger('Bovengrens', 1, 999, 70, true);
  nDnGrens := CreateParameterInteger('Ondergrens', 1, 999, 30, true);

{ Indicator eigenschappen }
  with Indicator do
  begin
    ShortName := 'DSS';
{ Aantal benodigde koersen om eerste indicatorwaarde te berekenen }
    RequiredBars := 2 * (nLength + 3);
  end;

  sTemp := MA(PctK(High, Low, Close, nLength), maExponential, 3);
  sDS := MA(PctK(sTemp, sTemp, sTemp, nLength), maExponential, 3);

  with CreateLine(sDS) do
  begin
    Name := 'DSS';
    Color := clRed;
    LineContent := lcTAR;
  end;
  with CreateLine(FillSeries(CreateSeries(BarCount), nUpGrens)) do
  begin
    Name := 'UpGrens';
    Color := clSilver;
    LineContent := lcConstant;
  end;
  with CreateLine(FillSeries(CreateSeries(BarCount), nDnGrens)) do
  begin
    Name := 'DnGrens';
    Color := clSilver;
    LineContent := lcConstant;
  end;
end.
Plaats reactie