分别为一周中的每一天打开关闭

Getting open close for each day of the week separately

我正在尝试写下每天的开盘价和收盘价,即我想一天一天地写下来,因此周一会将周一的开盘价写到一个 var 变量中,周二会记下星期二的开盘收盘价。然后,我将每天将这些值放入一个数组中,这是我能够做到的,但我无法想出一种有效获取这些数据的方法。我已经尝试过 dayofweek 的各种组合,但我失败了。

indicator("Daily open/close arrays", overlay = false)

var float[] monday_opens =      array.new_float()
var float[] monday_closes =     array.new_float()
var float[] tuesday_opens =     array.new_float()
var float[] tuesday_closes =    array.new_float()
var float[] wednesday_opens =   array.new_float()
var float[] wednesday_closes =  array.new_float()
var float[] thursday_opens =    array.new_float()
var float[] thursday_closes =   array.new_float()
var float[] friday_opens =      array.new_float()
var float[] friday_closes =     array.new_float()
var float[] saturday_opens =    array.new_float()
var float[] saturday_closes =   array.new_float()
var float[] sunday_opens =      array.new_float()
var float[] sunday_closes =     array.new_float()

new_day = ta.change(dayofweek) != 0
eod = time_close == time_close("D") and barstate.isconfirmed

if new_day
    if dayofweek == dayofweek.monday
        array.unshift(monday_opens, open)
    else if dayofweek == dayofweek.tuesday
        array.unshift(tuesday_opens, open)
    else if dayofweek == dayofweek.wednesday
        array.unshift(wednesday_opens, open)
    else if dayofweek == dayofweek.thursday
        array.unshift(thursday_opens, open)
    else if dayofweek == dayofweek.friday
        array.unshift(friday_opens, open)
    else if dayofweek == dayofweek.saturday
        array.unshift(saturday_opens, open)
    else if dayofweek == dayofweek.sunday
        array.unshift(sunday_opens, open)

if eod
    if dayofweek == dayofweek.monday
        array.unshift(monday_closes, close)
    else if dayofweek == dayofweek.tuesday
        array.unshift(tuesday_closes, close)
    else if dayofweek == dayofweek.wednesday
        array.unshift(wednesday_closes, close)
    else if dayofweek == dayofweek.thursday
        array.unshift(thursday_closes, close)
    else if dayofweek == dayofweek.friday
        array.unshift(friday_closes, close)
    else if dayofweek == dayofweek.saturday
        array.unshift(saturday_closes, close)
    else if dayofweek == dayofweek.sunday
        array.unshift(sunday_closes, close)