如何获得最高和最低的柱线索引

问题描述

你好,这是我的脚本,我将其从MQL4转换为Pinescript,无法正常工作,我测试了llb和hhb返回值,该值是索引的值,而不是该索引的值,我该如何解决

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © hesamx98

//@version=4
study("My Script")

hhb = highest(high,bar_index)[24]
llb = lowest(low,bar_index)[24]

if bar_index == hhb
    label.set_text(hhb,"Buy")
    label.set_color(hhb,color.green)
    label.set_yloc(hhb,yloc.belowbar)
    label.set_style(hhb,label.style_labelup)
    
if bar_index == llb
    label.set_text(llb,"Sell")
    label.set_color(llb,color.red)
    label.set_yloc(llb,yloc.abovebar)
    label.set_style(llb,label.style_labeldown)

解决方法

您要传入bar_index作为函数lengthhighest的{​​{1}}参数,然后……的价值来自24个吧之前。

我猜你打算做这样的事情:

lowest