Channel Exit

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

Channel Exit

Bericht door Eric » vr jun 08, 2007 10:51 am

Ad Nooten bespreekt in de TKA van juni 2007 een aantal stoploss systemen, waaronder de Channel Exit van Chuck Lebeau. Meer info over deze exitstrategie is te vinden op http://www.traderclub.com/discus/messag ... 19991207pm.

Code: Selecteer alles

{- Filename: Channel Exit -}

{ zie http://www.traderclub.com/discus/messages/107/440.html?TuesdayNovember919991207pm }

type
  TState = (stUnknown, stLong, stShort);
  
function ChannelExit(sHigh, sLow, sClose: TSeries;
                     Periode: integer;
                     var sSignals: TBuySellSignals): TSeries;
var
  i, Count: integer;
  Stop: real;
  State: TState;
begin
  Count := GetArrayLength(Close);
  Result := CreateSeries(Count);
  SetArrayLength(sSignals, Count);
  
  State := stUnknown;
  for i:=0 to Count-1 do
  begin
    if i >= Periode then
    begin
      case State of
        stLong:
        begin
          if Close[i] <= Stop then
          begin
            State := stShort;
            Stop := Highest(High, i-Periode+1, i);
            sSignals[i] := sgEnterShort;
          end else
            Stop := Lowest(Low, i-Periode+1, i);
          Result[i] := Stop;
        end;
        stShort:
        begin
          if Close[i] >= Stop then
          begin
            State := stLong;
            Stop := Lowest(Low, i-Periode+1, i);
            sSignals[i] := sgEnterLong;
          end else
            Stop := Highest(High, i-Periode+1, i);
          Result[i] := Stop;
        end else
        begin
          if Close[i] <= Lowest(Low, i-Periode, i-1) then
          begin
            State := stShort;
            Stop := Highest(High, i-Periode+1, i);
          end else
          if Close[i] >= Highest(High, i-Periode, i-1) then
          begin
            State := stLong;
            Stop := Lowest(Low, i-Periode+1, i);
          end;
        end;
      end;
    end;
  end;
end;

var
  Periode: integer;
  sChannelExit: TSeries;
begin
{ Indicator parameters }
  Periode := CreateParameterInteger('Periode', 1, 999, 5, true);

{ Indicator eigenschappen }
  with Indicator do 
  begin
    NewBand := false;
    ScaleRange := srCommon;
{ Aantal benodigde koersen om eerste indicatorwaarde te berekenen }
    RequiredBars := 3*Periode;
  end;

  sChannelExit := ChannelExit(High, Low, Close, Periode, Signals);

  with CreateLine(sChannelExit) do
  begin
    Name := 'ChannelExit';
    Color := clSilver;
  end;
end.

Plaats reactie