Daily pivot points in intraday chart

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

Daily pivot points in intraday chart

Bericht door Eric » wo mei 24, 2006 3:08 pm

Met deze indicator kunt u de pivot points, berekend over de dagkoersen, weergeven in de intraday grafiek. De indicator laat de lijnen zien:
- Avg = (H+L+C) / 3
- 2*Avg - L
- 2*Avg - H
- Avg + H - L
- Avg - H + L

Code: Selecteer alles

{- Filename: Pivots (daily) in intraday chart -}

var
  i, LastDay: integer;
  PivotAvg, PivotHigh, PivotLow, SuperPivotHigh, SuperPivotLow: TSeries;
  LastHigh, LastLow, LastClose, Avg: real;
begin
{ Indicator eigenschappen }
  with Indicator do 
  begin
    ShortName := 'Pivot points';
    RequiredBars := 2;
    NewBand := false;
    ScaleRange := srCommon;
  end;

  LastDay := -1;
  PivotAvg := CreateSeries(BarCount);
  PivotHigh := CreateSeries(BarCount);
  PivotLow := CreateSeries(BarCount);
  SuperPivotHigh := CreateSeries(BarCount);
  SuperPivotLow := CreateSeries(BarCount);
  for i:=0 to BarCount-1 do
  begin
    if i > 0 then
    begin
      PivotAvg[i] := PivotAvg[i-1];
      PivotHigh[i] := PivotHigh[i-1];
      PivotLow[i] := PivotLow[i-1];
      SuperPivotHigh[i] := SuperPivotHigh[i-1];
      SuperPivotLow[i] := SuperPivotLow[i-1];
    end;

    if trunc(DateTime[i]) <> LastDay then
    begin
      if LastDay > 0 then
      begin
        Avg := (LastHigh + LastLow + LastClose) / 3;
        PivotAvg[i] := Avg;
        PivotHigh[i] := 2 * Avg - LastLow;
        PivotLow[i] := 2 * Avg - LastHigh;
        SuperPivotHigh[i] := Avg + LastHigh - LastLow;
        SuperPivotLow[i] := Avg - LastHigh + LastLow;
      end;
      LastDay := trunc(DateTime[i]);
      LastHigh := High[i];
      LastLow := Low[i];
      LastClose := Close[i];
    end else
    begin
      LastHigh := Max(LastHigh, High[i]);
      LastLow := Min(LastLow, Low[i]);
      LastClose := Close[i];
    end;
  end;
  
  CreateLine(PivotAvg).Color := clWhite;
  CreateLine(PivotHigh).Color := clYellow;
  CreateLine(PivotLow).Color := clYellow;
  CreateLine(SuperPivotHigh).Color := clRed;
  CreateLine(SuperPivotLow).Color := clRed;
end.

Plaats reactie