对应于Ta.Lowest()长度的变量将始终是一个恒定值。为什么?
对不起,但是让我问你一个问题。 该脚本的目的是找到最低的价格到最近的高价。
我遇到的问题是,变量“距离”在“ ta.lowest”的计算中不使用更新值。 每个条的“距离”增加+1。 这可以通过图确认。 但是,如果我在“ ta.lowest”中使用变量“距离”,则将始终是“ 11”的值。 (也许初始值10 +计数1) 你知道为什么吗?
//@version=5
strategy("test")
var float hi_price = 0.0 //highest price
var int distance = 10 //Number of bars from the highest price
distance := distance + 1 //count up
float lowest = ta.lowest(low,distance) //lowest price up to the recent high
if(hi_price <= high)
hi_price := high
distance := 0
plot(distance) //confirming value of "distance"
plot(lowest) //confirming value of "lowest"
Excuse me, but let me ask you a question.
The purpose of this script is to find the lowest price up to the recent high.
The problem I have is that the variable "distance" does not use the updated value in the calculation of "ta.lowest".
The "distance" increases by +1 for each bar.
This can be confirmed with plot.
However, if I use the variable "distance" in "ta.lowest", it will always be a value of "11".
(maybe initial value 10 + count up 1)
Do you know why?
//@version=5
strategy("test")
var float hi_price = 0.0 //highest price
var int distance = 10 //Number of bars from the highest price
distance := distance + 1 //count up
float lowest = ta.lowest(low,distance) //lowest price up to the recent high
if(hi_price <= high)
hi_price := high
distance := 0
plot(distance) //confirming value of "distance"
plot(lowest) //confirming value of "lowest"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回到图表的开始,我的意思是第一个栏,您会看到您的脚本在那里工作。
问题是:
距离
因为它们每次都会增加距离时,它在每次运行中都指向相同的位置(在每个“下一个” bar上您已经进步了1个bar,但使用1个barback增加了回避,因此您的ta.lowest()每次都回到同一栏)。
由于令牌/股票的起点最低,因此通常不会发现任何较低的值。对于每个股票/代币都不是正确的,但这是通常的情况。
Go back to the start of the chart, I mean to the very first bar and you will see your script works there.
The issue is that:
distance
As you increase distance every time, it is pointing the same location on every run (on every "next" bar you have progressed 1 bar, but increased lookback with 1 so your ta.lowest() goes back to the same bar every time).
And as tokens/stocks are the lowest around their start, you won't find any lower value usually. This is not true for every stock/token but that's the usual case.