PROTECTED SOURCE SCRIPT
Pivot Tops & Bottoms (Enhanced Accuracy)

User Inputs
pivotLen: how many bars to look back on each side when identifying a pivot.
showTops / showBottoms: toggles for drawing top- and bottom-markers.
useATRFilter & atrMult: whether to filter out tiny pivots by requiring their high-low range to exceed ATR×multiplier.
useRSIFilter, rsiLen, rsiOB, rsiOS: optional RSI filter that only permits tops when RSI≥overbought or bottoms when RSI≤oversold.
Raw Pivot Detection
ta.pivothigh(high, pivotLen, pivotLen) returns a true on the bar that confirms a local high (i.e. that bar’s high is higher than the preceding and following pivotLen bars).
ta.pivotlow(low, pivotLen, pivotLen) does the same for local lows.
ATR Filter
We compute ATR over the same lookback (ta.atr(pivotLen)).
We check that the pivot bar’s range (high[pivotLen] – low[pivotLen]) is at least atr * atrMult.
If useATRFilter is off, this check is skipped.
RSI Filter
We compute RSI over rsiLen bars.
For a top, we require rsi[pivotLen] ≥ rsiOB; for a bottom, rsi[pivotLen] ≤ rsiOS.
If useRSIFilter is off, this check is skipped.
Combining Conditions
validTop = raw pivot-high AND (ATR filter passes OR disabled) AND (RSI filter passes OR disabled).
validBottom = raw pivot-low AND (ATR filter passes OR disabled) AND (RSI filter passes OR disabled).
Plotting in Real Time
We call plotshape() with no offset, so as soon as the pivot is confirmed (i.e. once enough future bars exist), the marker appears immediately on that bar.
Red triangles above bars mark tops; green triangles below mark bottoms.
The result is a cleaner pivot indicator: it still only “knows” about a pivot once the lookahead window is filled, but noise is reduced by the ATR and/or RSI filters, and you see your markers as soon as they’re confirmed.
pivotLen: how many bars to look back on each side when identifying a pivot.
showTops / showBottoms: toggles for drawing top- and bottom-markers.
useATRFilter & atrMult: whether to filter out tiny pivots by requiring their high-low range to exceed ATR×multiplier.
useRSIFilter, rsiLen, rsiOB, rsiOS: optional RSI filter that only permits tops when RSI≥overbought or bottoms when RSI≤oversold.
Raw Pivot Detection
ta.pivothigh(high, pivotLen, pivotLen) returns a true on the bar that confirms a local high (i.e. that bar’s high is higher than the preceding and following pivotLen bars).
ta.pivotlow(low, pivotLen, pivotLen) does the same for local lows.
ATR Filter
We compute ATR over the same lookback (ta.atr(pivotLen)).
We check that the pivot bar’s range (high[pivotLen] – low[pivotLen]) is at least atr * atrMult.
If useATRFilter is off, this check is skipped.
RSI Filter
We compute RSI over rsiLen bars.
For a top, we require rsi[pivotLen] ≥ rsiOB; for a bottom, rsi[pivotLen] ≤ rsiOS.
If useRSIFilter is off, this check is skipped.
Combining Conditions
validTop = raw pivot-high AND (ATR filter passes OR disabled) AND (RSI filter passes OR disabled).
validBottom = raw pivot-low AND (ATR filter passes OR disabled) AND (RSI filter passes OR disabled).
Plotting in Real Time
We call plotshape() with no offset, so as soon as the pivot is confirmed (i.e. once enough future bars exist), the marker appears immediately on that bar.
Red triangles above bars mark tops; green triangles below mark bottoms.
The result is a cleaner pivot indicator: it still only “knows” about a pivot once the lookahead window is filled, but noise is reduced by the ATR and/or RSI filters, and you see your markers as soon as they’re confirmed.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.