OPEN-SOURCE SCRIPT

45-Minute Range

//version=5
indicator("45-Minute Range", overlay=true)

// Define the start time (9:15 AM) and the end time (10:00 AM) in Indian stock market hours
var float rangeHigh = na
var float rangeLow = na
var bool rangeSet = false

// Define the session start (9:15) and end (15:30) times
startTime = timestamp(year, month, dayofmonth, 9, 15)
endTime = timestamp(year, month, dayofmonth, 15, 30)

// Capture high and low in the first 45 minutes of trading (9:15 AM - 10:00 AM)
if (hour == 9 and minute >= 15 and minute <= 59) or (hour == 10 and minute == 0)
rangeHigh := na(rangeHigh) ? high : math.max(rangeHigh, high)
rangeLow := na(rangeLow) ? low : math.min(rangeLow, low)

// Reset the range at the start of a new trading day
if (hour == 9 and minute == 15)
rangeHigh := na
rangeLow := na
rangeSet := false

// Plot the range after 10:00 AM with dotted lines, only for the current day
if (hour >= 10 and not rangeSet)
// Draw dotted line for high and low from 9:15 AM to 15:30 PM
line.new(x1=startTime, y1=rangeHigh, x2=endTime, y2=rangeHigh, color=color.green, width=2, style=line.style_dotted, xloc=xloc.bar_time)
line.new(x1=startTime, y1=rangeLow, x2=endTime, y2=rangeLow, color=color.red, width=2, style=line.style_dotted, xloc=xloc.bar_time)

rangeSet := true

// Optionally, plot the range on the chart
plot(rangeHigh, color=color.green, linewidth=2, title="45 Min High")
plot(rangeLow, color=color.red, linewidth=2, title="45 Min Low")
Bands and Channels

Script open-source

In pieno spirito TradingView, l'autore di questo script lo ha pubblicato open-source, in modo che i trader possano comprenderlo e verificarlo. Un saluto all'autore! È possibile utilizzarlo gratuitamente, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Vuoi usare questo script sui tuoi grafici?

Declinazione di responsabilità