Altucher Bollinger Bands strategie

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

Altucher Bollinger Bands strategie

Bericht door Eric » wo jan 25, 2006 12:37 pm

In TKA magazine van jan. 2006 is een aantal handelssystemen van James Altucher behandeld, waaronder deze Bollinger Bands strategie.

Code: Selecteer alles

{- Filename: Altucher BolBand Strategie -}

const
  sHelpText = 'Buy at Trigger % below the lower BollingerBand, and sell '+
    'at the take profit level or after 4 days.';
  
var
  Period, TriggerPct, TargetPct: integer;
  Width, TradePrice: real;
  UpperBand, LowerBand, MidLine, Trigger: TSeries;
  i, TradeIndex: integer;
  LineCrossings: TLineCrossings;
begin
  Period := CreateParameterInteger('Period', 1, 99, 10, true);
  Width := CreateParameterReal('Width', 0, 99, 1.5, true);
  TriggerPct := CreateParameterInteger('Trigger %', 1, 500, 20, true);
  TargetPct := CreateParameterInteger('Profit %', 1, 100, 15, true);

  with Indicator do
  begin
    RequiredBars := Period;
    NewBand := false;
    ScaleRange := srCommon;
    SignalView := svShowInMain;
    HelpText := sHelpText;
  end;
  
  MidLine := MA(Close, maSimple, Period);
  UpperBand := BollingerBand(Close, Period, maSimple, Width);
  LowerBand := BollingerBand(Close, Period, maSimple, -Width);
  Trigger := SubtractSeries(LowerBand, MultiplySeriesBy(SubtractSeries(UpperBand, LowerBand), TriggerPct/100));

  with CreateLine(MidLine) do Color := clYellow;
  with CreateLine(UpperBand) do Color := clSilver;
  with CreateLine(LowerBand) do Color := clSilver;
  with CreateLine(Trigger) do Color := clRed;

  LineCrossings := Crossings(Trigger, Close);

  for i:=0 to BarCount-1 do
  begin
{ market entry condition (long only) }
    if LineCrossings[i] = lc1Over2 then
    begin
      EnterLong(i);
      TradePrice := Close[i];
      TradeIndex := i;
    end else
    if (MarketPosition(i) > 0) and (TradePrice > 0) then
    begin
{ market exit condition }
      if (TradeIndex < i-3) or
         (((Close[i] - TradePrice) / TradePrice * 100) > TargetPct) then
        ExitLong(i);
    end;
  end;
end.

Plaats reactie