Multibegar

Multibegar

//@version=5
strategy("52-Week High/Low Breakout Strategy", overlay=true)

// Define 52-week high and low
lookbackPeriod = 52 * 5 // 52 weeks * 5 trading days in a week
highest52Week = ta.highest(high, lookbackPeriod)
lowest52Week = ta.lowest(low, lookbackPeriod)

// Buy condition: Close above the 52-week high
buyCondition = close > highest52Week // for accessing the previous value
if (buyCondition)
strategy.entry("Buy", strategy.long)

// Sell condition: Close below the 52-week low
sellCondition = close < lowest52Week
if (sellCondition)
strategy.entry("Sell", strategy.short)

// Plot the levels for visual reference
plot(highest52Week, color=color.green, linewidth=2, title="52-Week High")
plot(lowest52Week, color=color.red, linewidth=2, title="52-Week Low")

Read More

Share:

Latest News