I am trying to get tradingview pinescript ta.atr function to parse out the dayofweek function. Basically I wanted to see the difference in a securities movement depending on the day of the week. But the ta.atr function only allows length input, not a source.
mon = dayofweek.monday and ta.atr(4)
plot(mon, title='Monday', color=color.blue)
You can do something like this and push the ATR value of whatever day you want into an Array. Then from there you can find an average or whatever you are looking for.
//@version=5
indicator("My script")
atr = ta.atr(1)
var atrArr = array.new<float>()
if dayofweek == dayofweek.monday
atrArr.unshift(atr)
plot(atr)
if barstate.islast
last5 = ''
for i = 0 to 4
last5 := last5 + '[' + str.tostring(i) + '] ' + str.tostring(atrArr.get(i)) + '\n'
label.new(bar_index, atr, last5, color = color.fuchsia)