//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)
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
