PureBytes Links
Trading Reference Links
|
Richard Josslin <oldfogey@xxxxxxxxxx> asked:
>I offer $20 for the best submission (in my judgment) for Easy Language
>program code (for use in TS 3.5) for the following Show-Me study:
>
>1. First, identifies (by a dot on the low of the bar) "Low Pivots": any bar
>whose Low is lower than the Lows of the two immediately adjacent bars to its
>left and the two immediately adjacent bars to its right, with the proviso
>that two immediately adjacent bars having identical Lows shall be considered
>to be one bar.
>
>2. Second, once a Low Pivot has been identified, identifies (by a dot on
>the high of the bar) its "Second Higher High": the nearest bar to the left
>of the Low Pivot whose High is higher than the "First Higher High": the
>nearest bar to the left of the Low Pivot whose High is higher than the High
>of the Low Pivot.
>
>3. Ditto for High Pivot and its Second Lower Low, using reciprocal rules.
The code below should do the trick:
{* Search for pivot, defined as a low with two higher lows on either side
* then mark the Nth previous high that's higher than the high of the pivot bar.
* The pivot may consist of two equal lows.
* Reciprocal specs apply to high pivot, and lower lows.
* From an idea by Richard Josslin
* jimo, Sun Feb 22 20:05:31 1998
*}
input: Nth(2); { How many highs/lows to search for }
var: x(0), n(0), { general index }
break(0), { loop breaker }
px(0), { index of leftmost pivot bar }
ppx(0), { index of pivot bar with extreme High/Low }
lastextreme(0); { running extreme High/Low }
{*
* Low pivot:
*}
if L > L[1] and L[1] > L[2] { Find pivot pattern }
and ((L[2] < L[3] and L[3] < L[4])
or (L[2] = L[3] and L[3] < L[4] and L[4] < L[5]))
then begin
if L[2] = L[3] then begin { Account for equal-low pivot bars }
px = 3;
if H[2] > H[3] then
ppx = 2
else
ppx = 3;
end else begin
px = 2;
ppx = 2;
end;
lastextreme = H[ppx]; { Remember pivot High }
x = px; { Search for Nth Highest High }
break = 0;
n = 1;
while break = 0 and x < MaxBarsBack begin
x = x + 1;
if H[x] > lastextreme then begin
lastextreme = H[x];
n = n + 1;
if n > Nth then
break = 1;
end;
end;
plot1[ppx](L[ppx], "Lopivot");
if x < MaxBarsBack then
plot2[x](H[x], "NthHigh");
end;
{*
* High pivot:
*}
if H < H[1] and H[1] < H[2] { Find pivot pattern }
and ((H[2] > H[3] and H[3] > H[4])
or (H[2] = H[3] and H[3] > H[4] and H[4] > H[5]))
then begin
if H[2] = H[3] then begin { Account for equal-low pivot bars }
px = 3;
if L[2] < L[3] then
ppx = 2
else
ppx = 3;
end else begin
px = 2;
ppx = 2;
end;
lastextreme = L[ppx]; { Remember pivot Low }
x = px; { Search for Nth Lowest Low }
break = 0;
n = 1;
while break = 0 and x < MaxBarsBack begin
x = x + 1;
if L[x] < lastextreme then begin
lastextreme = L[x];
n = n + 1;
if n > Nth then
break = 1;
end;
end;
plot3[ppx](H[ppx], "Hipivot");
if x < MaxBarsBack then
plot4[x](L[x], "NthLow");
end;
|