PureBytes Links
Trading Reference Links
|
Hi Everyone -
I've gotten some private requests for the code of the finished indicator.
Though it was posted by Bob Fulks earlier today, I will do it again.
Perhaps some of you will make some changes and/or find some clever uses to
feed it with different input indicators and post the results. I for one,
would be very interested in what uses or mods are tried.
Later,
Tom Cathey
BTW, read the previous posts we've made to get a description of what it does
and how it evolved.
As follows:
--------------------
{Designed by Tom Cathey, and heavily modified and debugged by Bob Fulks}
{High/Low Swing Pivot Indicator}
Input: Length(20), Strength(5), Mode(2);
Var: MA(Close), Trend(0), SLo1(0), SLo2(0), SHi1(0), SHi2(0);
MA = Average(Close, Length);
Value1 = SwingLow(1, MA, Strength, Strength+1); {Find SwingLow}
Value2 = SwingHigh(1, MA, Strength, Strength+1); {Find SwingHigh}
if Value1 > 0 then begin
SLo2 = SLo1; {Save previous SwingLow}
SLo1 = Value1; {Get new SwingLow}
if Mode = 1 then Plot1[Strength](SLo1, "Low");
end;
if Value2 > 0 then begin
SHi2 = SHi1; {Save previous SwingHigh}
SHi1 = Value2; {Get new SwingHigh}
if Mode = 1 then Plot2[Strength](SHi1, "High");
end;
if SLo1 > 0 and SLo2 > 0 and SHi1 > 0 and SHi2 > 0 then begin
if SLo1 > SLo2 and SHi1 > SHi2 then Trend = 1;
{Established Uptrend, higher lows and higher highs }
if Trend = 1 and MA < SLo1 then Trend = -1;
{If SwingLow gets broken, then immediate -1}
if SLo1 > SLo2 and SHi1 < SHi2 then Trend = 0; {Triangle - Trendless}
if SLo1 < SLo2 and SHi1 < SHi2 then Trend = -1;
{Established DownTrend, lower lows and lower highs}
if Trend = -1 and MA > SHi1 then Trend = 1;
{If SwingHigh Gets Broken then immediate +1}
end;
if Mode = 2 then Plot3(Trend, "Trend");
if Mode = 1 then begin
Plot4(MA, "MA");
Plot1(SLo1, "Low");
Plot2(SHi1, "High");
end;
|