79600724

Date: 2025-04-30 16:21:25
Score: 2
Natty:
Report link

any one please provide me correct pine script because of this script show agai-again error .

//@version=5
strategy("Pivot Breakout with 20 SMA", overlay=true, margin_long=100, margin_short=100)

// Inputs
use_percent = input.bool(title="Use % for TP/SL", defval=true)
tp_perc     = input.float(title="Take Profit (%)", defval=1.0)
sl_perc     = input.float(title="Stop Loss (%)",  defval=0.5)
tp_points   = input.float(title="Take Profit (points)", defval=10.0)
sl_points   = input.float(title="Stop Loss (points)",  defval=5.0)

// Previous day OHLC
prevHigh  = request.security(syminfo.tickerid, "D", high[1])
prevLow   = request.security(syminfo.tickerid, "D", low[1])
prevClose = request.security(syminfo.tickerid, "D", close[1])

// Pivot points
pp = (prevHigh + prevLow + prevClose) / 3
r1 = 2 * pp - prevLow
s1 = 2 * pp - prevHigh
r2 = pp + (prevHigh - prevLow)
s2 = pp - (prevHigh - prevLow)
sma20 = ta.sma(close, 20)

// Plotting
plot(pp, title="Pivot PP", color=color.blue)
plot(r1, title="R1", color=color.green)
plot(s1, title="S1", color=color.red)
plot(r2, title="R2", color=color.new(color.green, 50), style=plot.style_dashed)
plot(s2, title="S2", color=color.new(color.red, 50), style=plot.style_dashed)
plot(sma20, title="20 SMA", color=color.orange)

// Conditions
breakPrevHigh = close > prevHigh and close[1] <= prevHigh
breakR1 = close > r1 and close[1] <= r1
buySignal = (breakPrevHigh or breakR1) and (close > sma20)

breakPrevLow = close < prevLow and close[1] >= prevLow
breakS1 = close < s1 and close[1] >= s1
sellSignal = (breakPrevLow or breakS1) and (close < sma20)

// Pre-calculate SL/TP values
sl_long = use_percent ? close * (1 - sl_perc / 100) : close - sl_points
tp_long = use_percent ? close * (1 + tp_perc / 100) : close + tp_points
sl_short = use_percent ? close * (1 + sl_perc / 100) : close + sl_points
tp_short = use_percent ? close * (1 - tp_perc / 100) : close - tp_points

// Entry and exit for long
if (buySignal)
    strategy.entry("Long", strategy.long)
    strategy.exit("Exit Long", from_entry="Long", stop=sl_long, limit=tp_long)

// Entry and exit for short
if (sellSignal)
    strategy.entry("Short", strategy.short)
    strategy.exit("Exit Short", from_entry="Short", stop=sl_short, limit=tp_short)

// Plot signals
plotshape(buySignal, title="Buy", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(sellSignal, title="Sell", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
Reasons:
  • RegEx Blacklisted phrase (2.5): please provide me
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Roshan Thakur