OPEN-SOURCE SCRIPT

OR + PM + PD + Daily Pivot (Labels Fixed)

123
//version=5
indicator("OR + PM + PD + Daily Pivot (Labels Fixed)", overlay=true)

// -------------------- Time --------------------
h = hour(time)
m = minute(time)
newDay = ta.change(time("D"))

// -------------------- Premarket & Opening Range --------------------
isPremarket = (h >= 4 and h < 9) or (h == 9 and m < 30)
isOpenRange = h == 9 and m >= 30 and m <= 35

// -------------------- Previous Day High / Low --------------------
pdh = request.security(syminfo.tickerid, "D", high[1])
pdl = request.security(syminfo.tickerid, "D", low[1])
plot(pdh, color=color.red, title="PDH")
plot(pdl, color=color.green, title="PDL")
if newDay
label.new(bar_index, pdh, "PDH", style=label.style_label_left, color=color.red, textcolor=color.white)
label.new(bar_index, pdl, "PDL", style=label.style_label_left, color=color.green, textcolor=color.white)

// -------------------- Pre-Market High / Low --------------------
var float pmh = na
var float pml = na
var bool pmLabelsPlotted = false

if newDay
pmh := na
pml := na
pmLabelsPlotted := false

if isPremarket
pmh := na(pmh) ? high : math.max(pmh, high)
pml := na(pml) ? low : math.min(pml, low)

plot(pmh, color=color.orange, title="PMH")
plot(pml, color=color.orange, title="PML")

if not isPremarket and not na(pmh) and not pmLabelsPlotted
label.new(bar_index, pmh, "PMH", style=label.style_label_left, color=color.orange, textcolor=color.black)
label.new(bar_index, pml, "PML", style=label.style_label_left, color=color.orange, textcolor=color.black)
pmLabelsPlotted := true

// -------------------- 5-Min High / Low --------------------
fiveHigh = request.security(syminfo.tickerid, "5", high)
fiveLow = request.security(syminfo.tickerid, "5", low)
var float fiveH = na
var float fiveL = na
var bool fiveLabelsPlotted = false

if newDay
fiveH := na
fiveL := na
fiveLabelsPlotted := false

if isOpenRange
fiveH := na(fiveH) ? fiveHigh : math.max(fiveH, fiveHigh)
fiveL := na(fiveL) ? fiveLow : math.min(fiveL, fiveLow)

plot(fiveH, color=color.blue, title="5m High")
plot(fiveL, color=color.blue, title="5m Low")

if not isOpenRange and not na(fiveH) and not fiveLabelsPlotted
label.new(bar_index, fiveH, "5m H", style=label.style_label_left, color=color.blue, textcolor=color.white)
label.new(bar_index, fiveL, "5m L", style=label.style_label_left, color=color.blue, textcolor=color.white)
fiveLabelsPlotted := true

// -------------------- 15-M

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.