Pivot Points (High/Low), also known as Bar Count Reversals, are used to anticipate potential price reversals. Pivot Point Highs are determined by the number of bars with lower highs on either side of a Pivot Point High. Pivot Point Lows are determined by the number of bars with higher lows on either side of a Pivot Point Low.
For example, a Pivot Point High, with a period of 5, requires a minimum of 11 bars to be considered a valid Pivot Point. A minimum of 5 bars before and after the Pivot Point High all have to have lower highs.
The default period is set to 10 (p=10). It means that the whole calculation are made within 11 bars (10 bars with a pivot bar on the middle of them).
(coded by request on English forum)
//PRC_PivotHiLo
//30.08.2016
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
p = 10
period = round(p/2)+1
hh = high[period]
ll = low[period]
countH = 0
countL = 0
for i = 1 to period-1 do
if high[i]<hh then
countH=countH+1
endif
if low[i]>ll then
countL=countL+1
endif
next
for i = period+1 to p+1 do
if high[i]<hh then
countH=countH+1
endif
if low[i]>ll then
countL=countL+1
endif
next
if countH=p then
pivotH = high[period]
endif
if countL=p then
pivotL = low[period]
endif
RETURN pivotH, pivotL