OPEN-SOURCE SCRIPT

15-Min Candle Breakout Strategy

117
//version=5
indicator("15-Min Candle Breakout Strategy", overlay=true)

// Define the session start time
startHour = 9
startMinute = 15

// Track the first 15-minute candle
isSessionStart = (hour == startHour and minute == startMinute)

var float firstHigh = na
var float firstLow = na

if (isSessionStart)
firstHigh := high
firstLow := low

// Draw the high and low lines
line.new(x1=bar_index[1], y1=firstHigh, x2=bar_index, y2=firstHigh, color=color.green, width=1)
line.new(x1=bar_index[1], y1=firstLow, x2=bar_index, y2=firstLow, color=color.red, width=1)

// Breakout signals
longSignal = (close > firstHigh)
shortSignal = (close < firstLow)

plotshape(longSignal, style=shape.labelup, color=color.green, size=size.small, location=location.belowbar, text="BUY")
plotshape(shortSignal, style=shape.labeldown, color=color.red, size=size.small, location=location.abovebar, text="SELL")

// Visualize breakout range
bgcolor(longSignal ? color.new(color.green, 90) : shortSignal ? color.new(color.red, 90) : na)

alertcondition(longSignal, title="Long Signal", message="Price broke above the first 15-min candle high")
alertcondition(shortSignal, title="Short Signal", message="Price broke below the first 15-min candle low")

// Optional: Reset the high and low at the start of the next day
if (hour == 0 and minute == 0)
firstHigh := na
firstLow := na

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.