OPEN-SOURCE SCRIPT
ATR + High/Lows

//version=6
indicator('ATR + Values', overlay = true)
// ========================
// === User Inputs ===
// ========================
showATR = input.bool(true, 'Show ATR/Move Table')
showHLR = input.bool(true, 'Show HL/R Table')
atrLength = input.int(14, 'ATR Period')
textColor = input.color(color.rgb(247, 242, 242), 'Default Text Color')
backgroundCol = input.color(color.rgb(0, 0, 0), 'Background Color')
rowOffset = input.int(0, 'Vertical Offset (rows)', minval = 0, maxval = 10)
colOffset = input.int(0, 'Horizontal Offset (columns)', minval = 0, maxval = 100)
var string tz = 'America/New_York'
// ========================
// === ATR / Move Logic ===
// ========================
dailyATRseries = request.security(syminfo.tickerid, 'D', ta.atr(atrLength), lookahead = barmerge.lookahead_off)
dailyATRprev = dailyATRseries[1]
newDayID = year(time, tz) * 10000 + month(time, tz) * 100 + dayofmonth(time, tz)
var int lastDayID = na
var float dayHigh = na
var float dayLow = na
var float fixedATR = na
isNewSession = na(lastDayID) or newDayID != lastDayID
after4am = hour(time, tz) >= 4
firstBarAfter4 = isNewSession and after4am and not(hour(time[1], tz) >= 4 and newDayID == year(time[1], tz) * 10000 + month(time[1], tz) * 100 + dayofmonth(time[1], tz))
if firstBarAfter4
dayHigh := high
dayLow := low
lastDayID := newDayID
fixedATR := dailyATRprev
else
dayHigh := math.max(dayHigh, high)
dayLow := math.min(dayLow, low)
intradayRange = dayHigh - dayLow
moveBg = intradayRange > fixedATR ? color.new(color.red, 77) : color.new(color.teal, 74)
// ========================
// === ATR + Move Table ===
// ========================
var table atrTable = table.new(position.top_right, 1, 2, border_width = 1, border_color = color.rgb(255, 255, 255))
if barstate.islast and showATR
table.clear(atrTable, 0, 0)
// Row 0: ATR Value
table.cell(atrTable, 0, 0, str.tostring(fixedATR, format.mintick),
bgcolor=color.rgb(0, 0, 0),
text_color=color.rgb(247, 242, 242),
text_halign=text.align_center)
// Row 1: Move Value (colored)
table.cell(atrTable, 0, 1, str.tostring(intradayRange, format.mintick),
bgcolor=moveBg,
text_color=color.rgb(247, 242, 242),
text_halign=text.align_center)
else
table.clear(atrTable, 0, 0)
// ========================
// === HL / Range Logic ===
// ========================
prevHigh = high[1]
prevLow = low[1]
currHigh = high
currLow = low
rangeHL = currHigh - currLow
rangeHL1 = prevHigh - prevLow
col1Text = str.tostring(rangeHL1, '0.00')
col2Text = str.tostring(prevHigh, '0.00') + '\n' + str.tostring(prevLow, '0.00')
col3Text = str.tostring(currHigh, '0.00') + '\n' + str.tostring(currLow, '0.00')
col4Text = str.tostring(rangeHL, '0.00')
prevColor = close[1] > open[1] ? color.rgb(64, 224, 208) : color.rgb(253, 143, 100)
currColor = close > open ? color.rgb(64, 224, 208) : color.rgb(253, 143, 100)
// ========================
// === HL / Range Table ===
// ========================
var table hlTable = table.new(position.top_center, 4 + colOffset, rowOffset + 1)
if barstate.islast and showHLR
for row = 0 to rowOffset by 1
for col = 0 to 3 + colOffset by 1
table.cell(hlTable, col, row, '', bgcolor = na)
row = rowOffset
colStart = colOffset
table.cell(hlTable, colStart + 0, row, col1Text, text_color = textColor, bgcolor = backgroundCol, text_halign = text.align_center, text_size = size.large)
table.cell(hlTable, colStart + 1, row, col2Text, text_color = prevColor, bgcolor = backgroundCol, text_halign = text.align_center, text_size = size.normal)
table.cell(hlTable, colStart + 2, row, col3Text, text_color = currColor, bgcolor = backgroundCol, text_halign = text.align_center, text_size = size.normal)
table.cell(hlTable, colStart + 3, row, col4Text, text_color = textColor, bgcolor = backgroundCol, text_halign = text.align_center, text_size = size.large)
else
table.clear(hlTable, 0, 0)
indicator('ATR + Values', overlay = true)
// ========================
// === User Inputs ===
// ========================
showATR = input.bool(true, 'Show ATR/Move Table')
showHLR = input.bool(true, 'Show HL/R Table')
atrLength = input.int(14, 'ATR Period')
textColor = input.color(color.rgb(247, 242, 242), 'Default Text Color')
backgroundCol = input.color(color.rgb(0, 0, 0), 'Background Color')
rowOffset = input.int(0, 'Vertical Offset (rows)', minval = 0, maxval = 10)
colOffset = input.int(0, 'Horizontal Offset (columns)', minval = 0, maxval = 100)
var string tz = 'America/New_York'
// ========================
// === ATR / Move Logic ===
// ========================
dailyATRseries = request.security(syminfo.tickerid, 'D', ta.atr(atrLength), lookahead = barmerge.lookahead_off)
dailyATRprev = dailyATRseries[1]
newDayID = year(time, tz) * 10000 + month(time, tz) * 100 + dayofmonth(time, tz)
var int lastDayID = na
var float dayHigh = na
var float dayLow = na
var float fixedATR = na
isNewSession = na(lastDayID) or newDayID != lastDayID
after4am = hour(time, tz) >= 4
firstBarAfter4 = isNewSession and after4am and not(hour(time[1], tz) >= 4 and newDayID == year(time[1], tz) * 10000 + month(time[1], tz) * 100 + dayofmonth(time[1], tz))
if firstBarAfter4
dayHigh := high
dayLow := low
lastDayID := newDayID
fixedATR := dailyATRprev
else
dayHigh := math.max(dayHigh, high)
dayLow := math.min(dayLow, low)
intradayRange = dayHigh - dayLow
moveBg = intradayRange > fixedATR ? color.new(color.red, 77) : color.new(color.teal, 74)
// ========================
// === ATR + Move Table ===
// ========================
var table atrTable = table.new(position.top_right, 1, 2, border_width = 1, border_color = color.rgb(255, 255, 255))
if barstate.islast and showATR
table.clear(atrTable, 0, 0)
// Row 0: ATR Value
table.cell(atrTable, 0, 0, str.tostring(fixedATR, format.mintick),
bgcolor=color.rgb(0, 0, 0),
text_color=color.rgb(247, 242, 242),
text_halign=text.align_center)
// Row 1: Move Value (colored)
table.cell(atrTable, 0, 1, str.tostring(intradayRange, format.mintick),
bgcolor=moveBg,
text_color=color.rgb(247, 242, 242),
text_halign=text.align_center)
else
table.clear(atrTable, 0, 0)
// ========================
// === HL / Range Logic ===
// ========================
prevHigh = high[1]
prevLow = low[1]
currHigh = high
currLow = low
rangeHL = currHigh - currLow
rangeHL1 = prevHigh - prevLow
col1Text = str.tostring(rangeHL1, '0.00')
col2Text = str.tostring(prevHigh, '0.00') + '\n' + str.tostring(prevLow, '0.00')
col3Text = str.tostring(currHigh, '0.00') + '\n' + str.tostring(currLow, '0.00')
col4Text = str.tostring(rangeHL, '0.00')
prevColor = close[1] > open[1] ? color.rgb(64, 224, 208) : color.rgb(253, 143, 100)
currColor = close > open ? color.rgb(64, 224, 208) : color.rgb(253, 143, 100)
// ========================
// === HL / Range Table ===
// ========================
var table hlTable = table.new(position.top_center, 4 + colOffset, rowOffset + 1)
if barstate.islast and showHLR
for row = 0 to rowOffset by 1
for col = 0 to 3 + colOffset by 1
table.cell(hlTable, col, row, '', bgcolor = na)
row = rowOffset
colStart = colOffset
table.cell(hlTable, colStart + 0, row, col1Text, text_color = textColor, bgcolor = backgroundCol, text_halign = text.align_center, text_size = size.large)
table.cell(hlTable, colStart + 1, row, col2Text, text_color = prevColor, bgcolor = backgroundCol, text_halign = text.align_center, text_size = size.normal)
table.cell(hlTable, colStart + 2, row, col3Text, text_color = currColor, bgcolor = backgroundCol, text_halign = text.align_center, text_size = size.normal)
table.cell(hlTable, colStart + 3, row, col4Text, text_color = textColor, bgcolor = backgroundCol, text_halign = text.align_center, text_size = size.large)
else
table.clear(hlTable, 0, 0)
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.