如何从系列中提取单个值?
我想创建一个系列,其中每个值都标准化为系列中特定元素的值,例如最新值。
如果您尝试使用其他通用语言来使用的语法:
normalized_close = close / close[0]
结果将是1的数组,因为Pine相对于同一栏的收盘价(0偏移)的收盘价之间的比率。我想相对于最新栏的单个收盘价,在每个栏的收盘价之间获得比率。在伪代码中,它看起来像这样。
latest_close = get_value_at_index(close, 0)
normalized_close = close / latest_close
函数get_value_at_index(系列,索引)
是我似乎找不到的功能。
I want to create a series in which every value is normalized to the value of a particular element in the series, for example the latest value.
If you try syntax that would work in other common languages:
normalized_close = close / close[0]
the result will be an array of 1's because Pine is taking the ratio between the closing price relative to the closing price of the same bar (0 offset). I want to get the ratio between the closing price in each bar relative to the single closing price of the latest bar. In pseudocode, it would look something like this.
latest_close = get_value_at_index(close, 0)
normalized_close = close / latest_close
Where the function get_value_at_index(series, index)
is the function I can't seem to find.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建
array
,用循环的设置其值,并在所需的任何索引中获取值。
这是一个以1000
关闭
价格的索引的示例,并从3个bars获得结果:You can create an
array
, set its values with afor
loop and get the value at any index you want.Here is an example with seeting an index with 1000
close
prices and getting the result from 3 bars ago: