英文:
Find the Lowest between 2 Conditions
问题
我想找到在之前的inside_bar
和longCondition
之间的最高值。
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 <= high[1] and low >= 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 > highest_val) // Update
highest_val := high
// Check the value of highest_val when longCondition is true
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论