如何在柱开盘时找到布林带的第一个值

发布于 2025-01-16 21:29:33 字数 354 浏览 1 评论 0原文

实际上,布林带代码是:

//@version=4
study(title="AAAA", shorttitle="AAAA", overlay=true)

len = 5
multi = 2

bb5med = sma(close, len)
devBB5 =  mult2 * stdev(close, len)
bb5top =  bb5med + devBB5
bb5bot =  bb5med - devBB5

当新柱出现时,即当收盘==开盘时,我想找到这三条线的第一个值。

另外,当我将 len 更改为 20、50 和/或将 multi 更改为 3 时,我需要它才能工作,

请帮助我。谢谢。

Actually, the Bollinger Bands code is:

//@version=4
study(title="AAAA", shorttitle="AAAA", overlay=true)

len = 5
multi = 2

bb5med = sma(close, len)
devBB5 =  mult2 * stdev(close, len)
bb5top =  bb5med + devBB5
bb5bot =  bb5med - devBB5

I would want to find the first value of those 3 lines when the new bar comes, means, when close==open.

Also, I need it to work when I change the len to 20, 50 and/or when I change the multi to 3

Please help me. Thank you.

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

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

发布评论

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

评论(1

素食主义者 2025-01-23 21:29:33
//@version=5
indicator("BB Open", overlay = true)

len = input.int(20)
mult = input.float(2.000)

basis = (math.sum(close, len - 1)[1] + open) / len

float dev_sum = 0.0

for i = 1 to len - 1
    dev_sum += math.pow(basis - close[i], 2)

dev_sum += math.pow(basis - open, 2)

stdev = math.sqrt(dev_sum / len)

up = basis + stdev * mult
dn = basis - stdev * mult

plot(basis, color = color.yellow)
plot(up)
plot(dn)

功能 :

f_BBopen(_close, _open, _len, _mult) =>
    _basis = (math.sum(_close, _len - 1)[1] + _open) / _len

    float _dev_sum = 0.0

    for i = 1 to _len - 1
        _dev_sum += math.pow(_basis - _close[i], 2)

    _dev_sum += math.pow(_basis - _open, 2)

    _stdev = math.sqrt(_dev_sum / _len)

    _up = _basis + _stdev * _mult
    _dn = _basis - _stdev * _mult
    [_basis, _up, _dn]

[basis, up, dn] = f_BBopen(close, open, len, mult)
//@version=5
indicator("BB Open", overlay = true)

len = input.int(20)
mult = input.float(2.000)

basis = (math.sum(close, len - 1)[1] + open) / len

float dev_sum = 0.0

for i = 1 to len - 1
    dev_sum += math.pow(basis - close[i], 2)

dev_sum += math.pow(basis - open, 2)

stdev = math.sqrt(dev_sum / len)

up = basis + stdev * mult
dn = basis - stdev * mult

plot(basis, color = color.yellow)
plot(up)
plot(dn)

Function :

f_BBopen(_close, _open, _len, _mult) =>
    _basis = (math.sum(_close, _len - 1)[1] + _open) / _len

    float _dev_sum = 0.0

    for i = 1 to _len - 1
        _dev_sum += math.pow(_basis - _close[i], 2)

    _dev_sum += math.pow(_basis - _open, 2)

    _stdev = math.sqrt(_dev_sum / _len)

    _up = _basis + _stdev * _mult
    _dn = _basis - _stdev * _mult
    [_basis, _up, _dn]

[basis, up, dn] = f_BBopen(close, open, len, mult)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文