对应于Ta.Lowest()长度的变量将始终是一个恒定值。为什么?

发布于 2025-01-19 09:20:37 字数 607 浏览 1 评论 0原文

对不起,但是让我问你一个问题。 该脚本的目的是找到最低的价格到最近的高价。

我遇到的问题是,变量“距离”在“ 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 技术交流群。

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

发布评论

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

评论(1

寒尘 2025-01-26 09:20:37

回到图表的开始,我的意思是第一个栏,您会看到您的脚本在那里工作。

问题是:

  • 您始终增加距离
  • 令牌/股票价格通常是最低的,

因为它们每次都会增加距离时,它在每次运行中都指向相同的位置(在每个“下一个” 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:

  • you always increase distance
  • token/stock prices are usually the lowest when they start

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.

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