Files
QuanTAlib/lib/reversals/fractals/fractals.pine
T
Miha Kralj 24e86d762a Add documentation links for various volatility indicators and channels
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links.
- Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
2026-02-18 11:55:48 -08:00

35 lines
1.5 KiB
Plaintext

// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("Williams Fractals", "FRACTALS", overlay=true)
//@function Detects Williams Fractal patterns (5-bar pattern)
//@returns [up_fractal, down_fractal] Fractal values (na if no fractal)
fractals() =>
bool is_up_fractal = false
bool is_down_fractal = false
if bar_index >= 4
is_up_fractal := high[2] > high[4] and high[2] > high[3] and high[2] > high[1] and high[2] > high[0]
is_down_fractal := low[2] < low[4] and low[2] < low[3] and low[2] < low[1] and low[2] < low[0]
float up_fractal_value = is_up_fractal ? high[2] : na
float down_fractal_value = is_down_fractal ? low[2] : na
[up_fractal_value, down_fractal_value]
// ---------- Main loop ----------
// Inputs
i_show_up = input.bool(true, "Show Up Fractals", tooltip="Display bearish fractals (resistance)")
i_show_down = input.bool(true, "Show Down Fractals", tooltip="Display bullish fractals (support)")
i_color_up = input.color(color.red, "Up Fractal Color")
i_color_down = input.color(color.green, "Down Fractal Color")
// Calculation
[up_fractal, down_fractal] = fractals()
// Plot fractal markers
plotshape(i_show_up and not na(up_fractal) ? up_fractal : na, "Up Fractal", style=shape.triangledown, location=location.absolute, color=i_color_up, size=size.small, offset=-2)
plotshape(i_show_down and not na(down_fractal) ? down_fractal : na, "Down Fractal", style=shape.triangleup, location=location.absolute, color=i_color_down, size=size.small, offset=-2)