Tom DeMark Range Expansion Index

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

Tom DeMark Range Expansion Index

Bericht door Eric » do mei 10, 2007 2:25 pm

In de TKA van mei 2007 bespreken Ed Kiers en Paul Menzing de Range Expansion Index van Tom DeMark.

Hierbij de TA-script implementatie van hun interpretatie van de indicator:

Code: Selecteer alles

{- Filename: TD Range Expansion Index -}

const 
  sHelpText = 'Tom Demark Range Expansion Index.';

var
  i, nLookBack, nPeriod, nUpperBand, nLowerBand: integer;
  bUseEqual, b1, b2: boolean;
  sDeltaHigh, sDeltaLow, sDeltaSum, sAbsPriceMove, sREI, sUpperBand, sLowerBand: TSeries;
  xUpperBand, xLowerBand: TLineCrossings;
begin
  nLookBack := CreateParameterInteger('Lookback', 1, 999, 2, true);
  bUseEqual := CreateParameterBoolean('UseEqual', true, true);
  nPeriod := CreateParameterInteger('Periode', 1, 999, 5, true);
  nUpperBand := CreateParameterInteger('Upper Band', 1, 999, 45, true);
  nLowerBand := CreateParameterInteger('Lower Band', 1, 999, -45, true);

{ Setup indicator properties } 
  with Indicator do 
  begin 
    ShortName := 'REI';
    HelpText := sHelpText;
    RequiredBars := MaxInt(nLookBack, 8) + nPeriod;
  end;

  sDeltaHigh := Momentum(High, nLookBack);
  sDeltaLow := Momentum(Low, nLookBack);
  sDeltaSum := AddSeries(sDeltaHigh, sDeltaLow);
  sAbsPriceMove := AddSeries(AbsSeries(sDeltaHigh), AbsSeries(sDeltaLow));

  for i:=8 to BarCount-1 do
  begin
    if IsValid(sDeltaHigh[i]) and IsValid(sDeltaLow[i]) then
    begin
      if bUseEqual then
      begin
        b1 := ((High[i] >= Low[i-5]) or (High[i] >= Low[i-6])) and
              ((Low[i] <= High[i-5]) or (Low[i] <= High[i-6]));
        b2 := ((High[i-2] >= Close[i-7]) or (High[i-2] >= Close[i-8])) and
              ((Low[i-2] <= Close[i-7]) or (Low[i-2] <= Close[i-8]));
      end else
      begin
        b1 := ((High[i] > Low[i-5]) or (High[i] > Low[i-6])) and
              ((Low[i] < High[i-5]) or (Low[i] < High[i-6]));
        b2 := ((High[i-2] > Close[i-7]) or (High[i-2] > Close[i-8])) and
              ((Low[i-2] < Close[i-7]) or (Low[i-2] < Close[i-8]));
      end;
      if not b1 and not b2 then sDeltaSum[i] := 0;
    end;
  end;

  sREI := DivideSeries(MA(sDeltaSum, maSimple, nPeriod),
                       MA(sAbsPriceMove, maSimple, nPeriod));
  sREI := MultiplySeriesBy(sREI, 100);
  sUpperBand := FillSeries(CreateSeries(BarCount), nUpperBand);
  sLowerBand := FillSeries(CreateSeries(BarCount), nLowerBand);

{ signalen bepalen }
  xUpperBand := Crossings(sREI, sUpperBand);
  xLowerBand := Crossings(sREI, sLowerBand);
  for i:=0 to BarCount-1 do
  begin
    if xUpperBand[i] = lc1Over2 then EnterShort(i) else
    if xLowerBand[i] = lc2Over1 then EnterLong(i);
  end;
  
  with CreateLine(sREI) do
  begin
    Name := 'REI';
    Color := clLime;
  end;
  with CreateLine(sUpperBand) do
  begin
    Name := 'UpperBand';
    Color := clSilver;
    LineContent := lcConstant;;
  end;
  with CreateLine(sLowerBand) do
  begin
    Name := 'LowerBand';
    Color := clSilver;
    LineContent := lcConstant;;
  end;
end.
---
Eric

Plaats reactie