PINE LIBRARY
reversal

Library "reversals"
psar(af_start, af_increment, af_max)
Calculates Parabolic Stop And Reverse (SAR)
Parameters:
af_start (simple float): Initial acceleration factor (Wilder's original: 0.02)
af_increment (simple float): Acceleration factor increment per new extreme (Wilder's original: 0.02)
af_max (simple float): Maximum acceleration factor (Wilder's original: 0.20)
Returns: SAR value (stop level for current trend)
fractals()
Detects Williams Fractal patterns (5-bar pattern)
Returns: Tuple [up_fractal, down_fractal] with fractal values (na if no fractal)
swings(lookback, source_high, source_low)
Detects swing highs and swing lows using lookback period
Parameters:
lookback (simple int): Number of bars on each side to confirm swing point
source_high (float): Price series for swing high detection (typically high)
source_low (float): Price series for swing low detection (typically low)
Returns: Tuple [swing_high, swing_low] with swing point values (na if no swing)
pivot(tf)
Calculates classic/standard/floor pivot points
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, s1, s2, s3] with pivot levels
pivotcam(tf)
Calculates Camarilla pivot points with 8 levels for short-term trading
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, r4, s1, s2, s3, s4] with pivot levels
pivotdem(tf)
Calculates d-mark pivot points with conditional open/close logic
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, s1] with pivot levels (only 3 levels)
pivotext(tf)
Calculates extended traditional pivot points with R4-R5 and S4-S5 levels
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, r4, r5, s1, s2, s3, s4, s5] with pivot levels
pivotfib(tf)
Calculates Fibonacci pivot points using Fibonacci ratios
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, s1, s2, s3] with pivot levels
pivotwood(tf)
Calculates Woodie's pivot points with weighted closing price
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, s1, s2, s3] with pivot levels
psar(af_start, af_increment, af_max)
Calculates Parabolic Stop And Reverse (SAR)
Parameters:
af_start (simple float): Initial acceleration factor (Wilder's original: 0.02)
af_increment (simple float): Acceleration factor increment per new extreme (Wilder's original: 0.02)
af_max (simple float): Maximum acceleration factor (Wilder's original: 0.20)
Returns: SAR value (stop level for current trend)
fractals()
Detects Williams Fractal patterns (5-bar pattern)
Returns: Tuple [up_fractal, down_fractal] with fractal values (na if no fractal)
swings(lookback, source_high, source_low)
Detects swing highs and swing lows using lookback period
Parameters:
lookback (simple int): Number of bars on each side to confirm swing point
source_high (float): Price series for swing high detection (typically high)
source_low (float): Price series for swing low detection (typically low)
Returns: Tuple [swing_high, swing_low] with swing point values (na if no swing)
pivot(tf)
Calculates classic/standard/floor pivot points
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, s1, s2, s3] with pivot levels
pivotcam(tf)
Calculates Camarilla pivot points with 8 levels for short-term trading
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, r4, s1, s2, s3, s4] with pivot levels
pivotdem(tf)
Calculates d-mark pivot points with conditional open/close logic
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, s1] with pivot levels (only 3 levels)
pivotext(tf)
Calculates extended traditional pivot points with R4-R5 and S4-S5 levels
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, r4, r5, s1, s2, s3, s4, s5] with pivot levels
pivotfib(tf)
Calculates Fibonacci pivot points using Fibonacci ratios
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, s1, s2, s3] with pivot levels
pivotwood(tf)
Calculates Woodie's pivot points with weighted closing price
Parameters:
tf (simple string): Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple [pp, r1, r2, r3, s1, s2, s3] with pivot levels
Biblioteca Pine
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Exención de responsabilidad
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Biblioteca Pine
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Exención de responsabilidad
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.