vasu1
no com// SR Break and Retest Indicator
// Inspired by ChartPrime Style
// Disclaimer: This script is for educational purposes only and does not constitute financial advice.
indicator("SR Break and Retest [ChartPrime Style]", shorttitle="SR_Break_Retest_CP", overlay=true)
pivotLen = input.int(10, title="Pivot Length")
retestBars = input.int(15, title="Retest Lookback")
showLabels = input.bool(true, title="Show Labels")
showZones = input.bool(true, title="Show SR Zones")
src = input.source(close, title="Source")
ph = talib.pivothigh(high, pivotLen, pivotLen)
pl = talib.pivotlow(low, pivotLen, pivotLen)
static float resistance = na
static float support = na
if not na(ph) {
resistance := ph
}
if not na(pl) {
support := pl
}
bullBreak = close > resistance and close[1] <= resistance
bearBreak = close < support and close[1] >= support
static float bullLevel = na
static float bearLevel = na
if bullBreak {
bullLevel := resistance
}
if bearBreak {
bearLevel := support
}
bullRetest = low <= bullLevel and close > bullLevel and talib.barssince(bullBreak) < retestBars
bearRetest = high >= bearLevel and close < bearLevel and talib.barssince(bearBreak) < retestBars
resColor = color.red
supColor = color.lime
plot(showZones ? resistance : na, title="Resistance", color=resColor, linewidth=2)
plot(showZones ? support : na, title="Support", color=supColor, linewidth=2)
plotshape(
bullBreak,
title="Bullish Break",
shape=shape.arrowup,
color=color.lime,
location=location.belowbar,
text="BREAK"
)
plotshape(
bearBreak,
title="Bearish Break",
shape=shape.arrowdown,
color=color.red,
location=location.abovebar,
text="BREAK"
)
plotshape(
bullRetest,
title="Bullish Retest",
shape=shape.circle,
color=color.green,
location=location.belowbar,
text="RETEST"
)
plotshape(
bearRetest,
title="Bearish Retest",
shape=shape.circle,
color=color.maroon,
location=location.abovebar,
text="RETEST"
)
if showLabels and bullBreak {
label.new(
bar_index,
low,
"Bull Break",
color=color.lime,
textcolor=color.black
)
}
if showLabels and bearBreak {
label.new(
bar_index,
high,
"Bear Break",
color=color.red,
textcolor=color.white
)
}
if showLabels and bullRetest {
label.new(
bar_index,
low,
"Bull Retest",
color=color.green,
textcolor=color.white
)
}
if showLabels and bearRetest {
label.new(
bar_index,
high,
"Bear Retest",
color=color.maroon,
textcolor=color.white
)
}
barcolor(
bullRetest ? color.lime :
bearRetest ? color.red :
na
)ments
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 GoCharting. Read more in the Terms of Use.
Comments (0)
Loading comments…
