[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EL Code Problem



PureBytes Links

Trading Reference Links

Try this (for a realtime chart, eg, 5-minute) ---

{ TS4 Show-Me Study to Calculate "Floor Traders' Support & Resistance"
according to formulae below }

Var: Hi(0),
  Lo(99999),
  YHi(0),
  YLo(99999),
  YCl(0),
  Pivot(0),
  R1(0),
  S1(0),
  R2(0),
  S2(0);

IF BarNumber = 1 OR Date[1] < Date THEN BEGIN
 YHi = Hi;
 YLo = Lo;
 YCl = C[1];
 Hi = H;
 Lo = L;
END ELSE BEGIN
 IF H > Hi THEN Hi = H;
 IF L < Lo THEN Lo = L;
END;

{ Formulae for "Support & Resistance" }

Pivot = (YHi + YLo + YCl) / 3;
R1 = (2 * Pivot) - YLo;
S1 = (2 * Pivot) - YHi;
R2 = (Pivot - S1) + R1;
S2 = Pivot - (R1 - S1);

IF Date = CurrentDate THEN BEGIN
 IF Date[1] < Date THEN BEGIN
  Plot1(R1,"R");
  Plot2(S1,"S");
  Plot3(Pivot,"Pivot");
 END ELSE if Date[2] < Date[1] THEN BEGIN
  IF C > R1 THEN Plot1(R2,"R");
  IF C < S1 THEN Plot2(S2,"S");
 END ELSE IF Mod(BarNumber,4) = 0 THEN BEGIN
  IF C > Pivot THEN BEGIN
   Plot1(R1,"R");
   Plot4(Pivot + (R1 - Pivot) / 2,"Half");
  END;
  IF C < Pivot THEN BEGIN
   Plot2(S1,"S");
   Plot4(Pivot - (Pivot - S1) / 2,"Half");
  END;
  Plot3(Pivot,"Pivot");
 END ELSE IF Mod(BarNumber,4) = 2 THEN BEGIN
  IF C > R1 THEN Plot1(R2,"R");
  If C < S1 THEN Plot2(S2,"S");
 END;
END;


{ Note: Plot1 & Plot2 must be plotted as "Points" and not as "Lines" }




Ron Hughes wrote:

> Hi Group,
>
>                 I seem to be having a problem with a bit of code I wrote
> for some pivots lines. I thought some of you in this group might be able
> to shed some light on the matter. The code is supposed to create
> Support/Resistance lines by referencing the prior day's high, low, and
> close. I've noticed, however, that the position of these lines changes
> whenever a new high or  low is reached. Obviously, I'm missing something
> here. Any ideas?
>
> Cheers,
>
> Ron.
>
>  Vars: Pivot(0), FirstR(0), FirstSup(0), SecR(0),SecSup(0);
>
> Pivot=3D(HighD(1)+ LowD(1) + CloseD(1)) / 3;
> FirstR =3D (2*Pivot) - LowD(1);
> FirstSup =3D (2*Pivot) - HighD(1);
> SecR =3D ((Pivot - FirstSup)+FirstR);
> SecSup =3D (Pivot - (SecR - FirstSup));
>
> Plot1 (FirstR,"R1");
> Plot2 ((FirstSup),"S1");
> Plot3 (SecR,"R2");
> Plot4 (SecSup,"S2");