找到两个条件中的最低值

huangapple go评论50阅读模式
英文:

Find the Lowest between 2 Conditions

问题

我想找到在之前的inside_barlongCondition之间的最高值。

inside_bar = high <= high[1] and low >= low[1]

longCondition = ta.crossover(a, b)

逻辑是当longCondition发生时,我想找到在它们之间(在longCondition之前形成的)的先前inside_bar,并找到它们之间的最高柱值。

以下是更好理解的屏幕截图:
https://prnt.sc/qtrgEnl6lHx6

英文:

I want to find the highest value between the previous inside_bar and longCondition.

inside_bar = high &lt;= high[1] and low &gt;= low[1] 

longCondition = ta.crossover(a, b)

The logic is when longCondition happens, I want to find the previous inside_bar (which formed before longCondition) and find the highest bar value between them.

Here's a screenshot for better understanding:
https://prnt.sc/qtrgEnl6lHx6

答案1

得分: 1

你可以使用var变量来做到这一点。当出现内部棒形态时,只需重置它,并在条件为true时检查其值。

var highest_val = high

if (inside_bar)
    highest_val := high      // 重置
else
    if (high > highest_val)  // 更新
        highest_val := high

// 在longCondition为true时检查highest_val的值
英文:

You can do that with a var variables. Just reset it when it is an inside bar and check its value when your condition is true.

var highest_val = high

if (inside_bar)
    highest_val := high      // Reset
else
    if (high &gt; highest_val)  // Update
        highest_val := high

// Check the value of highest_val when longCondition is true

huangapple
  • 本文由 发表于 2023年6月6日 16:16:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76412664.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定