如何在5个小节内找到哪个最高的高绿色条,不包括当前条?

发布于 2025-02-13 19:34:16 字数 288 浏览 1 评论 0原文

我想找到最后5个棒的最高高杠,而不是当前的棒(当前的棒可能是最高的绿色条,所以我需要排除它),

我尝试过,但似乎不正确

find = high == highest(high, 5) and close > open and bar_index > 0 and bar_index < 6
numb = barssince(find)
high_of_that_bar = high[numb]
low_of_that_bar = low[numb])

谢谢你帮助我

I would like to find the green bar which is the highest high bar of last 5 bars, and not the current bar (the current bar may be the highest green one, so I need to exclude it)

I tried this but it seems not correct

find = high == highest(high, 5) and close > open and bar_index > 0 and bar_index < 6
numb = barssince(find)
high_of_that_bar = high[numb]
low_of_that_bar = low[numb])

Thank you for helping me

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

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

发布评论

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

评论(1

傲世九天 2025-02-20 19:34:18

这应该做你想要的。

//@version=5
indicator("My script")

i_bars = input.int(5, "Bars back")

var float   green_hi    = 0
var float   green_lo    = 0
var label   lbl         = label.new(na, na, "")

if barstate.islast
    green_hi := 0
    for i = 1 to i_bars
        if close[i] > open[i] and high[i] > green_hi
            green_hi := high[i]
            green_lo := low[i]

    label.set_xy(lbl, bar_index+1, high)
    label.set_text(lbl, str.format("green within last {2} bars\nhigh = {0}\nlow = {1}", green_hi, green_lo, i_bars))

这显示了我有第二个意见的盘中时间范围的分数条形指数

//@version=5
indicator("My script")

i_bars = input.int(5, "Bars back")

var float   green_hi    = 0
var float   green_lo    = 0
var label   lbl         = label.new(na, na, "")
var int     mybarindex  = na
var int     mybar       = na
var int     myi         = na

if barstate.islast
    green_hi := 0
    for i = 1 to i_bars
        if close[i] > open[i] and high[i] > green_hi
            green_hi := high[i]
            green_lo := low[i]
            mybarindex := bar_index
            mybar := bar_index - i
            myi := i

    label.set_xy(lbl, bar_index+1, high)
    label.set_text(lbl, str.format("green within last {2} bars\nhigh = {0,number,#.#######}\nlow = {1,number,#.#######}\nmybar = {3}\nmybarindex = {4}\nmyi = {5}", green_hi, green_lo, i_bars, mybar, mybarindex, myi))

,而且看来bar_index毕竟不是分数。
str.format()只用逗号将数千个分开。

这很清楚:

//@version=5
indicator("My script")

i_bars = input.int(5, "Bars back")

var float   green_hi    = 0
var float   green_lo    = 0
var label   lbl         = label.new(na, na, "")
var int     mybarindex  = na
var int     mybar       = na
var int     myi         = na

if barstate.islast
    green_hi := 0
    for i = 1 to i_bars
        if close[i] > open[i] and high[i] > green_hi
            green_hi := high[i]
            green_lo := low[i]
            mybarindex := bar_index
            mybar := bar_index - i
            myi := i

    label.set_xy(lbl, bar_index+1, high)
    label.set_text(lbl, str.format("green within last {2} bars\nhigh = {0,number,#.#######}\nlow = {1,number,#.#######}\nmybar = {3}\nmybarindex = {4}\nmyi = {5}", green_hi, green_lo, i_bars, mybar, mybarindex, myi))

if barstate.islastconfirmedhistory
    label.new(bar_index - 10, high, str.format("{0}", bar_index + 0.1))

This should do what you want.

//@version=5
indicator("My script")

i_bars = input.int(5, "Bars back")

var float   green_hi    = 0
var float   green_lo    = 0
var label   lbl         = label.new(na, na, "")

if barstate.islast
    green_hi := 0
    for i = 1 to i_bars
        if close[i] > open[i] and high[i] > green_hi
            green_hi := high[i]
            green_lo := low[i]

    label.set_xy(lbl, bar_index+1, high)
    label.set_text(lbl, str.format("green within last {2} bars\nhigh = {0}\nlow = {1}", green_hi, green_lo, i_bars))

This shows the fractional bar-index for intraday timeframes

//@version=5
indicator("My script")

i_bars = input.int(5, "Bars back")

var float   green_hi    = 0
var float   green_lo    = 0
var label   lbl         = label.new(na, na, "")
var int     mybarindex  = na
var int     mybar       = na
var int     myi         = na

if barstate.islast
    green_hi := 0
    for i = 1 to i_bars
        if close[i] > open[i] and high[i] > green_hi
            green_hi := high[i]
            green_lo := low[i]
            mybarindex := bar_index
            mybar := bar_index - i
            myi := i

    label.set_xy(lbl, bar_index+1, high)
    label.set_text(lbl, str.format("green within last {2} bars\nhigh = {0,number,#.#######}\nlow = {1,number,#.#######}\nmybar = {3}\nmybarindex = {4}\nmyi = {5}", green_hi, green_lo, i_bars, mybar, mybarindex, myi))

I got a second opinion, and it seems bar_index is not fractional after all.
str.format() just separates thousands with commas.

This makes it clear:

//@version=5
indicator("My script")

i_bars = input.int(5, "Bars back")

var float   green_hi    = 0
var float   green_lo    = 0
var label   lbl         = label.new(na, na, "")
var int     mybarindex  = na
var int     mybar       = na
var int     myi         = na

if barstate.islast
    green_hi := 0
    for i = 1 to i_bars
        if close[i] > open[i] and high[i] > green_hi
            green_hi := high[i]
            green_lo := low[i]
            mybarindex := bar_index
            mybar := bar_index - i
            myi := i

    label.set_xy(lbl, bar_index+1, high)
    label.set_text(lbl, str.format("green within last {2} bars\nhigh = {0,number,#.#######}\nlow = {1,number,#.#######}\nmybar = {3}\nmybarindex = {4}\nmyi = {5}", green_hi, green_lo, i_bars, mybar, mybarindex, myi))

if barstate.islastconfirmedhistory
    label.new(bar_index - 10, high, str.format("{0}", bar_index + 0.1))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文