//version=5
indicator("Support/Resistance with Long/Short Entry & Exit", overlay=true)
// User Inputs
pivotLen = input.int(5, title="Pivot Length", minval=1)
sensitivity = input.float(1.5, title="Sensitivity (%)", step=0.1)
// Calculate pivot points for potential support (pivot lows) and resistance (pivot highs)
pivotHigh = ta.pivothigh(high, pivotLen, pivotLen)
pivotLow = ta.pivotlow(low, pivotLen, pivotLen)
// Plot pivot shapes for visual reference
plotshape(pivotHigh, title="Resistance Pivot", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.tiny)
plotshape(pivotLow, title="Support Pivot", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny)
// Store the most recent support and resistance levels
var float currentResistance = na
var float currentSupport = na
if not na(pivotHigh)
currentResistance := high[pivotLen]
if not na(pivotLow)
currentSupport := low[pivotLen]
// Plot the current support and resistance lines
plot(currentResistance, title="Resistance", style=plot.style_line, color=color.red, linewidth=2)
plot(currentSupport, title="Support", style=plot.style_line, color=color.green, linewidth=2)
// Define Long/Short Entry and Exit Conditions
// Long Entry: price closes above current resistance by the sensitivity percentage
longEntry = not na(currentResistance) and (close > currentResistance * (1 + sensitivity / 100))
// Long Exit: price closes below current support by the sensitivity percentage
longExit = not na(currentSupport) and (close < currentSupport * (1 - sensitivity / 100))
// Short Entry: price closes below current support by the sensitivity percentage
shortEntry = not na(currentSupport) and (close < currentSupport * (1 - sensitivity / 100))
// Short Exit: price closes above current resistance by the sensitivity percentage
shortExit = not na(currentResistance) and (close > currentResistance * (1 + sensitivity / 100))
// Plot signals on the chart for clarity
plotshape(longEntry, title="Long Entry", location=location.belowbar, color=color.blue, style=shape.arrowup, size=size.small)
plotshape(longExit, title="Long Exit", location=location.abovebar, color=color.orange, style=shape.arrowdown, size=size.small)
plotshape(shortEntry, title="Short Entry", location=location.abovebar, color=color.purple, style=shape.arrowdown, size=size.small)
plotshape(shortExit, title="Short Exit", location=location.belowbar, color=color.yellow, style=shape.arrowup, size=size.small)
indicator("Support/Resistance with Long/Short Entry & Exit", overlay=true)
// User Inputs
pivotLen = input.int(5, title="Pivot Length", minval=1)
sensitivity = input.float(1.5, title="Sensitivity (%)", step=0.1)
// Calculate pivot points for potential support (pivot lows) and resistance (pivot highs)
pivotHigh = ta.pivothigh(high, pivotLen, pivotLen)
pivotLow = ta.pivotlow(low, pivotLen, pivotLen)
// Plot pivot shapes for visual reference
plotshape(pivotHigh, title="Resistance Pivot", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.tiny)
plotshape(pivotLow, title="Support Pivot", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny)
// Store the most recent support and resistance levels
var float currentResistance = na
var float currentSupport = na
if not na(pivotHigh)
currentResistance := high[pivotLen]
if not na(pivotLow)
currentSupport := low[pivotLen]
// Plot the current support and resistance lines
plot(currentResistance, title="Resistance", style=plot.style_line, color=color.red, linewidth=2)
plot(currentSupport, title="Support", style=plot.style_line, color=color.green, linewidth=2)
// Define Long/Short Entry and Exit Conditions
// Long Entry: price closes above current resistance by the sensitivity percentage
longEntry = not na(currentResistance) and (close > currentResistance * (1 + sensitivity / 100))
// Long Exit: price closes below current support by the sensitivity percentage
longExit = not na(currentSupport) and (close < currentSupport * (1 - sensitivity / 100))
// Short Entry: price closes below current support by the sensitivity percentage
shortEntry = not na(currentSupport) and (close < currentSupport * (1 - sensitivity / 100))
// Short Exit: price closes above current resistance by the sensitivity percentage
shortExit = not na(currentResistance) and (close > currentResistance * (1 + sensitivity / 100))
// Plot signals on the chart for clarity
plotshape(longEntry, title="Long Entry", location=location.belowbar, color=color.blue, style=shape.arrowup, size=size.small)
plotshape(longExit, title="Long Exit", location=location.abovebar, color=color.orange, style=shape.arrowdown, size=size.small)
plotshape(shortEntry, title="Short Entry", location=location.abovebar, color=color.purple, style=shape.arrowdown, size=size.small)
plotshape(shortExit, title="Short Exit", location=location.belowbar, color=color.yellow, style=shape.arrowup, size=size.small)
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
