1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
134 lines of Pine Script v4 from Chad's Swing Points (expanded) copy.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
Chad's Swing Points (expanded) copy.pine
//@version=4
// Shows traditional fractal lows/highs (two lower/higher lows/highs on each side), as well as three bar lows/highs (one lower/higher low/high on each side)
// Basically an expansion on the default William's Fractal script to fit PA daytrading strategies.
// Probably rife with repainting issues, at least for alerts. Use at your own risk.
study("Chad's Swing Points (@tradeprophet)", overlay=true)
// START DEBUG
ds(str) => label.new(bar_index, high, str)
dsl(str) =>
if barstate.islast
ds(str)
d(val) => ds(tostring(val))
dl(val) => dsl(tostring(val))
// END DEBUG
var plotOffset = 3
var negativePlotOffset = plotOffset * -1
// Minor highs (3 bar pattern)
var isMinorHighShown = input(true, "Show Minor Highs?")
var isAllMinorHighPriceLabelShown = input(false, "Show All Minor High Price Labels?")
var isOnlyLastMinorHighPriceLabelShown = input(true, "Show Only Last Minor High Price Label?")
var lastMinorHighIndex = int(na)
var lastMinorHighPrice = float(na)
// Minor lows (3 bar pattern)
var isMinorLowShown = input(true, "Show Minor Lows?")
var isAllMinorLowPriceLabelShown = input(false, "Show All Minor Low Price Labels?")
var isOnlyLastMinorLowPriceLabelShown = input(true, "Show Only Last Minor Low Price Label?")
var lastMinorLowIndex = int(na)
var lastMinorLowPrice = float(na)
// Major Highs (5 par patterns)
var isMajorHighShown = input(true, "Show Major Highs?")
var isAllMajorHighPriceLabelShown = input(false, "Show All Major High Price Labels?")
var isOnlyLastMajorHighPriceLabelShown = input(true, "Show Only Last Major High Price Label?")
var lastMajorHighIndex = int(na)
var lastMajorHighPrice = float(na)
// Major Lows (5 bar patterns)
var isMajorLowShown = input(true, "Show Major Lows?")
var isAllMajorLowPriceLabelShown = input(false, "Show All Major Low Price Labels?")
var isOnlyLastMajorLowPriceLabelShown = input(true, "Show Only Last Major Low Price Label?")
var lastMajorLowIndex = int(na)
var lastMajorLowPrice = float(na)
// Minor highs (3 bar pattern)
isMinorHigh = (high[3] < high[2]) and (high[1] < high[2])
if isMinorHigh
lastMinorHighIndex := bar_index-plotOffset
lastMinorHighPrice := high[plotOffset]
// Minor lows (3 bar pattern)
isMinorLow = (low[3] > low[2]) and (low[1] > low[2])
if isMinorLow
lastMinorLowIndex:= bar_index-plotOffset
lastMinorLowPrice := low[plotOffset]
// Major Highs (5 par patterns)
isMajorHigh = isMinorHigh and (((high[5] < high[3]) and (high[1] < high[3]))
or ((high[6] < high[3]) and (high[5] < high[3]) and (high[5] == high[3]) and (high[4] <= high[3]) and (high[2] < high[3]) and (high[1] < high[3]))
or ((high[7] < high[3]) and (high[6] < high[3]) and (high[5] == high[3]) and (high[5] == high[3]) and (high[4] <= high[3]) and (high[2] < high[3]) and (high[1] < high[3]))
or ((high[8] < high[3]) and (high[7] < high[3]) and (high[6] == high[3]) and (high[5] <= high[3]) and (high[5] == high[3]) and (high[4] <= high[3]) and (high[2] < high[3]) and (high[1] < high[3])))
if isMajorHigh
lastMajorHighIndex:= bar_index+-plotOffset
lastMajorHighPrice := high[plotOffset]
// Major Lows (5 par patterns)
isMajorLow = isMinorLow and (((low[5] > low[3]) and (low[1] > low[3]))
or ((low[5] > low[3]) and (low[5] > low[3]) and (low[4] == low[3]) and (low[2] > low[3]) and (low[1] > low[3]))
or ((low[6] > low[3]) and (low[5] > low[3]) and (low[5] == low[3]) and (low[4] >= low[3]) and (low[2] > low[3]) and (low[1] > low[3]))
or ((low[7] > low[3]) and (low[6] > low[3]) and (low[5] == low[3]) and (low[5] == low[3]) and (low[4] >= low[3]) and (low[2] > low[3]) and (low[1] > low[3]))
or ((low[8] > low[3]) and (low[7] > low[3]) and (low[6] == low[3]) and (low[5] >= low[3]) and (low[5] == low[3]) and (low[4] >= low[3]) and (low[2] > low[3]) and (low[1] > low[3])))
if isMajorLow
lastMajorLowIndex := bar_index-plotOffset
lastMajorLowPrice := low[plotOffset]
//
// Plot them & create the alerts
//
createCurrentBarLabel(barindex, value, under) =>
label.new(barindex, value*(under ? 0.999 : 1.001), text=tostring(value), color=color.gray, style=under ? label.style_label_up : label.style_label_down)
createHighLabelAt(barindex, val) => createCurrentBarLabel(barindex, val, false)
createLowLabelAt(barindex, val) => createCurrentBarLabel(barindex, val, true)
createHighLabel() => createHighLabelAt(bar_index-plotOffset, high[plotOffset])
createLowLabel() => createLowLabelAt(bar_index-plotOffset, low[plotOffset])
// Minor highs
plotshape(isMinorHighShown and isMinorHigh and not isMajorHigh, style=shape.xcross, location=location.abovebar, offset=negativePlotOffset+1, color=color.black, transp=60, size = size.tiny)
alertcondition(high > lastMinorHighPrice, title="Chad's Minor High Breaks", message="Last minor high broke")
if(isAllMinorHighPriceLabelShown and not isOnlyLastMinorHighPriceLabelShown)
createHighLabel()
if(isOnlyLastMinorHighPriceLabelShown and barstate.islast)
createHighLabelAt(lastMinorHighIndex, lastMinorHighPrice)
// Minor lows
plotshape(isMinorLowShown and isMinorLow and not isMajorLow, style=shape.xcross, location=location.belowbar, offset=negativePlotOffset+1, color=color.black, transp=60, size = size.tiny)
alertcondition(low > lastMinorLowPrice, title="Chad's Minor Low Breaks", message="Last minor low broke")
if(isAllMinorLowPriceLabelShown and not isOnlyLastMinorHighPriceLabelShown)
createLowLabel()
if(isOnlyLastMinorLowPriceLabelShown and barstate.islast)
createLowLabelAt(lastMinorLowIndex, lastMinorLowPrice)
// Major highs
plotshape(isMajorHighShown and isMajorHigh, style=shape.circle, location=location.abovebar, offset=negativePlotOffset, color=color.black, transp=80, size = size.tiny)
alertcondition(high > lastMajorHighPrice, title="Chad's Major High Breaks", message="Last major high broke")
if(isAllMajorHighPriceLabelShown and not isOnlyLastMajorHighPriceLabelShown)
createHighLabel()
if(isOnlyLastMajorHighPriceLabelShown and barstate.islast)
createHighLabelAt(lastMajorHighIndex, lastMajorHighPrice)
// Major Lows
plotshape(isMajorLowShown and isMajorLow, style=shape.circle, location=location.belowbar, offset=negativePlotOffset, color=color.black, transp=80, size = size.tiny)
alertcondition(low > lastMajorLowPrice, title="Chad's Major Low Breaks", message="Last major low broke")
if(isAllMajorLowPriceLabelShown and not isOnlyLastMajorLowPriceLabelShown)
createLowLabel()
if(isOnlyLastMajorLowPriceLabelShown and barstate.islast)
createLowLabelAt(lastMajorLowIndex, lastMajorLowPrice)
Overview
Minor swings are calculated using a 3-bar pivot structure, while major swings expand upon traditional 5-bar Williams Fractals. Users can toggle the visibility of minor and major swing points and choose whether to display price labels for all historical swings or only the most recent one. Because pivot identification requires future bars to confirm local peaks and troughs, signals lag by several bars and will repaint prior bars upon confirmation.
Three-bar minor swing high and low detection
Five-bar major fractal swing identification
Configurable price labels for latest or historical pivots
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Show Minor Highs?
bool
true
isMinorHighShown
Show All Minor High Price Labels?
bool
false
isAllMinorHighPriceLabelShown
Show Only Last Minor High Price Label?
bool
true
isOnlyLastMinorHighPriceLabelShown
Show Minor Lows?
bool
true
isMinorLowShown
Show All Minor Low Price Labels?
bool
false
isAllMinorLowPriceLabelShown
Show Only Last Minor Low Price Label?
bool
true
isOnlyLastMinorLowPriceLabelShown
Show Major Highs?
bool
true
isMajorHighShown
Show All Major High Price Labels?
bool
false
isAllMajorHighPriceLabelShown
Show Only Last Major High Price Label?
bool
true
isOnlyLastMajorHighPriceLabelShown
Show Major Lows?
bool
true
isMajorLowShown
Show All Major Low Price Labels?
bool
false
isAllMajorLowPriceLabelShown
Show Only Last Major Low Price Label?
bool
true
isOnlyLastMajorLowPriceLabelShown
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator overlays up to five higher-timeframe candlestick groups on the price chart. For each enabled timeframe it requests open, high, low, and close and can show up to five candles, offset by a spacing setting. The main inputs set the candle count, the
This indicator plots optional candlestick pattern signals on the price chart. It detects engulfing bars, inside bars, HOLP and LOHP, kicker patterns, body-mass extremes, higher highs and lower lows, ATR warnings, and four-bar fractals. Optional pivot marks use
The Strat Assistant indicator identifies candlestick patterns from the STRAT methodology on the price chart. It detects inside bars, 2-candle directional bars, 3-candle outside bars, and sequences like 212 and 222 for continuations and reversals. Shapes such a
This overlay indicator highlights candles with a body smaller than 50% of their total range by coloring them white on the price chart. Simultaneously, it calculates and plots horizontal lines for open prices across multiple higher timeframes, such as daily, we
This Pine Script indicator identifies liquidity sweeps and confirms signals using a close-back candle pattern directly on the price chart. It tracks recent swing highs and lows over a customizable lookback period. A bullish signal forms when a prior bar sweeps
This overlay indicator draws 80/20 price levels and optional 40-point zone bands on the price chart. It marks repairs, cross sections, and forks with optional letter labels, and can highlight confluence when those marks sit near a level. Separate options shade