一周中的每一天分别开盘收盘

发布于 2025-01-10 00:38:51 字数 152 浏览 0 评论 0原文

我试图写下每天的开盘价和收盘价,即我想每天写下来,因此星期一将把星期一的开盘收盘价写到 var 变量中,而星期二将写下开盘收盘价星期二。然后,我将每天将这些值放入一个数组中,我可以做到这一点,但我无法想出一种有效获取这些数据的方法。我已经尝试过与 dayofweek 的各种组合,但失败了。

I'm trying to write down the open and close price of each day, namely I want to write it down day by day and hence that Monday will write down the open close for Monday into a var variable and Tuesday will write down the open close for Tuesday. I will then put these values into an array for each day, which I'm able to do, but I can't come up with a method to get this data efficiently. I've already tried various combinations with dayofweek, but I'm failing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泛滥成性 2025-01-17 00:38:51
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)
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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文